aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/encryptor.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/lib/encryptor.js')
-rw-r--r--app/scripts/lib/encryptor.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/scripts/lib/encryptor.js b/app/scripts/lib/encryptor.js
index 3d069ab33..832e6d528 100644
--- a/app/scripts/lib/encryptor.js
+++ b/app/scripts/lib/encryptor.js
@@ -22,6 +22,8 @@ module.exports = {
// Buffer <-> base64 string methods
encodeBufferToBase64,
decodeBase64ToBuffer,
+
+ generateSalt,
}
// Takes a Pojo, returns encrypted text.
@@ -135,3 +137,10 @@ function decodeBase64ToBuffer (base64) {
}))
return buf
}
+
+function generateSalt (byteCount = 32) {
+ var view = new Uint8Array(byteCount)
+ global.crypto.getRandomValues(view)
+ var b64encoded = btoa(String.fromCharCode.apply(null, view))
+ return b64encoded
+}