简体   繁体   中英

How to get the XOR key from a python file?

So, I have this encrypted file. I want the key so I can decrypt it. I don't want it in decrypted form, I want it in encrypted form and know the decryption process, or put into text form. Here is the function for the key:

def encrypt(input_data, password):
    key = 0
    for ch in password:
        key ^= ((2 * ord(ch) + 3) & 0xff)

    return xor(input_data, key)

How do I get the key to appear so I can decrypt it? I want it to print the key to a text file.

def encrypt(input_data, password):
    key = 0
    for ch in password:
        key ^= ((2 * ord(ch) + 3) & 0xff)

    with open('key.txt', 'w') as f:
        f.write("{0:b}".format(key).zfill(8))

    return xor(input_data, key)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM