
# 1 导包
from Crypto.Cipher import AES

enc_file = "ipdb_enc_ipv4_20230712.mmdb"
out_file = "out_file_ipv4"

def encrypt_or_decrypt(enc_file, out_file, key, iv):
    with open(enc_file, 'rb') as f_in:
        encrypted_data = f_in.read()
        cipher = AES.new(key, AES.MODE_CBC, iv)
        decrypted_data = cipher.decrypt(encrypted_data)
        with open(out_file, 'wb') as f_out:
            f_out.write(decrypted_data)
        return out_file

if __name__ == "__main__":
    encrypt_or_decrypt(enc_file,out_file)