diff options
author | Dan Finlay <dan@danfinlay.com> | 2016-10-21 02:33:18 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2016-10-21 02:33:18 +0800 |
commit | 383f8ea7dc4a264613cfe92b257878eb78438ce7 (patch) | |
tree | e476d190f97e60d3740f7650b318b8a7bb092a75 /app/scripts/lib | |
parent | e5c95d68f80eba3e3d4645f7ac1f6606d0dddd52 (diff) | |
download | tangerine-wallet-browser-383f8ea7dc4a264613cfe92b257878eb78438ce7.tar tangerine-wallet-browser-383f8ea7dc4a264613cfe92b257878eb78438ce7.tar.gz tangerine-wallet-browser-383f8ea7dc4a264613cfe92b257878eb78438ce7.tar.bz2 tangerine-wallet-browser-383f8ea7dc4a264613cfe92b257878eb78438ce7.tar.lz tangerine-wallet-browser-383f8ea7dc4a264613cfe92b257878eb78438ce7.tar.xz tangerine-wallet-browser-383f8ea7dc4a264613cfe92b257878eb78438ce7.tar.zst tangerine-wallet-browser-383f8ea7dc4a264613cfe92b257878eb78438ce7.zip |
Linted & added salting to vault
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/config-manager.js | 2 | ||||
-rw-r--r-- | app/scripts/lib/encryptor.js | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index d12304c46..ae4a84082 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -118,7 +118,7 @@ ConfigManager.prototype.setVault = function (encryptedString) { ConfigManager.prototype.getVault = function () { var data = this.getData() - return ('vault' in data) && data.vault + return ('vault' in data) && data.vault } ConfigManager.prototype.getKeychains = function () { 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) + })) +} |