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.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/scripts/lib/encryptor.js b/app/scripts/lib/encryptor.js
index 91d6ed5ce..8a3b0b023 100644
--- a/app/scripts/lib/encryptor.js
+++ b/app/scripts/lib/encryptor.js
@@ -18,6 +18,10 @@ module.exports = {
// Buffer <-> Hex string methods
serializeBufferForStorage,
serializeBufferFromStorage,
+
+ // Buffer <-> base64 string methods
+ encodeBufferToBase64,
+ decodeBase64ToBuffer,
}
// Takes a Pojo, returns encrypted text.
@@ -117,3 +121,15 @@ function unprefixedHex (num) {
}
return hex
}
+
+function encodeBufferToBase64 (buf) {
+ var b64encoded = btoa(String.fromCharCode.apply(null, buf))
+ return b64encoded
+}
+
+function decodeBase64ToBuffer (base64) {
+ var u8_2 = new Uint8Array(atob(b64encoded).split("")
+ .map(function(c) {
+ return c.charCodeAt(0)
+ }))
+}