Skip to main content

Method Signature

align.blockchain.wallets.decryptPrivateKey(
  encrypted: EncryptedWallet,
  password: string
): Promise<string>

Parameters

encrypted
EncryptedWallet
required
The encrypted wallet data object
password
string
required
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)}...`);
Handle decrypted private keys with extreme care. Never log them or expose them in client-side code.