04-12-2024, 11:39 AM
(This post was last modified: 04-12-2024, 11:44 AM by bingussssssss.)
import base58
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.backends import default_backend
from nacl.secret import SecretBox
from nacl.exceptions import CryptoError
data = {
"encrypted": "", # Replace with your actual encrypted data
"nonce": "",# Replace with your actual nonce
"salt": "", # Replace with your actual salt password
"iterations": 10000,
}
password = '' # Replace with your actual password
# Decode from Base58
salt = base58.b58decode(data['salt'])
nonce = base58.b58decode(data['nonce'])
encrypted_data = base58.b58decode(data['encrypted'])
# Derive the key using PBKDF2 with SHA-256
kdf = PBKDF2HMAC(
algorithm=hashes.SHA256(),
length=32,
salt=salt,
iterations=data['iterations'],
backend=default_backend()
)
key = kdf.derive(password.encode())
# Decrypt the data using PyNaCl's SecretBox
box = SecretBox(key)
try:
decrypted = box.decrypt(encrypted_data, nonce) # Your private key in hex string format
except CryptoError as e:
print(f"Decryption failed: {e}")
# Convert hex to bytes
entropy_bytes = binascii.unhexlify(decrypted.hex()))
# Generate mnemonic from the entropy bytes
mnemo = Mnemonic("english")
mnemonic = mnemo.to_mnemonic(entropy_bytes)
print("Mnemonic:", mnemonic)
Made it just one script which will print your Mnemonic -- Remember though, even the decrypted hex string is sensitive.
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.backends import default_backend
from nacl.secret import SecretBox
from nacl.exceptions import CryptoError
data = {
"encrypted": "", # Replace with your actual encrypted data
"nonce": "",# Replace with your actual nonce
"salt": "", # Replace with your actual salt password
"iterations": 10000,
}
password = '' # Replace with your actual password
# Decode from Base58
salt = base58.b58decode(data['salt'])
nonce = base58.b58decode(data['nonce'])
encrypted_data = base58.b58decode(data['encrypted'])
# Derive the key using PBKDF2 with SHA-256
kdf = PBKDF2HMAC(
algorithm=hashes.SHA256(),
length=32,
salt=salt,
iterations=data['iterations'],
backend=default_backend()
)
key = kdf.derive(password.encode())
# Decrypt the data using PyNaCl's SecretBox
box = SecretBox(key)
try:
decrypted = box.decrypt(encrypted_data, nonce) # Your private key in hex string format
except CryptoError as e:
print(f"Decryption failed: {e}")
# Convert hex to bytes
entropy_bytes = binascii.unhexlify(decrypted.hex()))
# Generate mnemonic from the entropy bytes
mnemo = Mnemonic("english")
mnemonic = mnemo.to_mnemonic(entropy_bytes)
print("Mnemonic:", mnemonic)
Made it just one script which will print your Mnemonic -- Remember though, even the decrypted hex string is sensitive.