import Align from "@tolbel/align";import fs from "fs";const align = new Align({ apiKey: process.env.ALIGN_API_KEY!, environment: "sandbox",});// Create a walletconst wallet = await align.blockchain.wallets.create();// Encrypt for storageconst encrypted = await align.blockchain.wallets.encryptPrivateKey( wallet.privateKey, "mySecurePassword123!");console.log(`Address: ${encrypted.address}`);// Save to filefs.writeFileSync( `./keystore/${encrypted.address}.json`, encrypted.encryptedJson);console.log("Wallet encrypted and saved!");
Encryption uses scrypt key derivation, which is deliberately slow (~3-5
seconds) to resist brute-force attacks.
Password Requirements: - Use a strong, unique password - Never store
passwords alongside encrypted wallets - Consider using a key management
service for production