Method Signature
align.blockchain.wallets.decryptPrivateKey(
encrypted: EncryptedWallet,
password: string
): Promise<string>
Parameters
The encrypted wallet data object
The password used for encryption
Returns
Returns the decrypted private key as a string.
Examples
import Align from "@tolbel/align";
const align = new Align({
apiKey: process.env.ALIGN_API_KEY!,
environment: "sandbox",
});
// First, encrypt a private key
const encrypted = await align.blockchain.wallets.encryptPrivateKey(
privateKey,
"mySecurePassword123!"
);
// Later, decrypt it
const decryptedKey = await align.blockchain.wallets.decryptPrivateKey(
encrypted,
"mySecurePassword123!"
);
console.log(`Decrypted: ${decryptedKey.slice(0, 10)}...`);
const decryptedKey = await align.blockchain.wallets.decryptPrivateKey(
encrypted,
password
);
Handle decrypted private keys with extreme care. Never log them or expose them
in client-side code.