import zipfile
import re
import xml.etree.ElementTree as ET
import sys
import os

def extract_text_from_xlsx(filepath):
    text_content = []
    try:
        with zipfile.ZipFile(filepath, 'r') as z:
            # Shared strings
            if 'xl/sharedStrings.xml' in z.namelist():
                with z.open('xl/sharedStrings.xml') as f:
                    tree = ET.parse(f)
                    root = tree.getroot()
                    # Namespace for spreadsheetml usually
                    # But simpler to just find all 't' tags
                    ns = {'main': 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'}
                    # ET usually handles namespaces annoyingly, so brute force finding 't' text
                    for elem in root.iter():
                        if elem.tag.endswith('}t'):
                             if elem.text:
                                 text_content.append(elem.text)
            
            # Also value in sheets directly if inlineStr? 
            # Often standard text is in sharedStrings.
            
    except Exception as e:
        print(f"Error reading xlsx: {e}")
        return ""
    
    return "\n".join(text_content)

target_file = "/Users/andrimustaqim/Downloads/Sekolah/OCBC_NISP_Virtual_Account_Specification_ SNAP (Version 2.12.0).xlsx"

if not os.path.exists(target_file):
    print(f"File not found: {target_file}")
    sys.exit(1)

content = extract_text_from_xlsx(target_file)
# Filter for interesting lines
keywords = ["Symmetric", "Simulator", "HMAC", "SHA512", "SHA256", "RSA", "Public Key", "Private Key"]
for line in content.split('\n'):
    for k in keywords:
        if k.lower() in line.lower():
            print(line)
