Skip to content

Instantly share code, notes, and snippets.

@mootinator
Created August 29, 2023 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mootinator/9ce00d49672b390245cc6e4da82afd93 to your computer and use it in GitHub Desktop.
Save mootinator/9ce00d49672b390245cc6e4da82afd93 to your computer and use it in GitHub Desktop.
var crypto = require('crypto');
// Your password goes here
var password = '***';
let utf8Encode = new TextEncoder();
async function generateKey(e, n) {
const r = await crypto.subtle.importKey("raw", e, "PBKDF2", !1, ["deriveBits", "deriveKey"]);
return crypto.subtle.deriveKey({
name: "PBKDF2",
salt: n,
iterations: 3e5,
hash: "SHA-256"
}, r, {
name: "AES-GCM",
length: 256
}, !0, ["encrypt", "decrypt"])
}
// Recovered wallet data goes here
var recovered = {"mnemonic":"","salt":[],"passwordIv":[]};
var pwd = utf8Encode.encode(password);
var salt = Buffer.from(recovered.salt);
generateKey(pwd, salt)
.then(k => {
var decrypted = crypto.subtle.decrypt({name:"AES-GCM",iv:Buffer.from(recovered.passwordIv)}, k, Buffer.from(recovered.mnemonic, 'base64'));
decrypted.then(plaintext => console.log(new TextDecoder().decode(plaintext)));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment