Hi. I reinstall app at own Iphone and lost own wallet but i dont save backupfile. Now i have 25 and 12 words and try create script to create backup but have error when write 12 word.
import os
import json
import base64
from Crypto.Cipher import AES
from Crypto.Protocol.KDF import scrypt
salt = os.urandom(16)
nonce = os.urandom(12)
def encrypt_data(data, password):
key = scrypt(password, salt, 32, N=2**14, r=8, p=1)
cipher = AES.new(key, AES.MODE_GCM, nonce=nonce)
ciphertext, tag = cipher.encrypt_and_digest(data)
return ciphertext, tag
backup_data = {
"mnemonic": "here mnemonic 25 words",
"accounts": ["account1", "account2"]
}
serialized_data = json.dumps(backup_data).encode()
password = b"here 12 words"
ciphertext, tag = encrypt_data(serialized_data, password)
backup_object = {
"ciphertext": base64.b64encode(ciphertext).decode(),
"salt": base64.b64encode(salt).decode(),
"nonce": base64.b64encode(nonce).decode(),
"tag": base64.b64encode(tag).decode(),
"version": "1.0",
"suite": "HMAC-SHA256:sodium_secretbox_easy"
}
backup_string = base64.b64encode(json.dumps(backup_object).encode()).decode()
backup_filename = "backup_result.txt"
with open(backup_filename, "w") as file:
file.write(backup_string)
print(f"Result: {backup_filename}")
Pls help
UPd_1 - be careffuly if someone give site with add your seed on them- example livesupports.app