summaryrefslogtreecommitdiff
path: root/encrypt_key.js
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2023-05-16 13:20:02 +0200
committerErich Eckner <git@eckner.net>2023-05-16 14:35:19 +0200
commitd6b68b7988fad876380e31816a113d7b3ba8ee02 (patch)
tree52fe2a56adbdf6787c9e8e2d0f339b0afec3192b /encrypt_key.js
parenta04faeeccdaeb7582ea096e436624bbaafbe39ab (diff)
downloadmocp-web-d6b68b7988fad876380e31816a113d7b3ba8ee02.tar.xz
genkey neu
Diffstat (limited to 'encrypt_key.js')
-rw-r--r--encrypt_key.js9
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;
+}