diff options
Diffstat (limited to 'encrypt_key.js')
-rw-r--r-- | encrypt_key.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/encrypt_key.js b/encrypt_key.js new file mode 100644 index 0000000..2a36177 --- /dev/null +++ b/encrypt_key.js @@ -0,0 +1,9 @@ +function encrypt_private_key(password, private_key) { + let public_key = private_key.substring(64,128); + let priv = sodium.from_hex(private_key.substring(0,64)); + if (password.length > 0) { + for (i=0; i<priv.length; i++) + priv[i] ^= password[i % password.length].charCodeAt(0); + } + return sodium.to_hex(priv) + public_key; +} |