Commit 9d42020d0c0999f33e691eec65d6216b095a2cab
method to generate a random encryption key (32 bytes as base64)
Dominic Tarr committed on 2/4/2017, 9:14:45 AMParent: 1f80eb811659fb473d6119b6cb642a511ad9466f
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -118,9 +118,9 @@ | ||
118 | 118 … | isBuffer(msg) ? msg : new Buffer(msg) |
119 | 119 … | ) |
120 | 120 … | } |
121 | 121 … | |
122 | -// OTHER CRYTPO FUNCTIONS | |
122 … | +// OTHER CRYPTO FUNCTIONS | |
123 | 123 … | |
124 | 124 … | exports.signObj = function (keys, hmac_key, obj) { |
125 | 125 … | if(!obj) obj = hmac_key, hmac_key = null |
126 | 126 … | var _obj = clone(obj) |
@@ -157,4 +157,9 @@ | ||
157 | 157 … | var msg = pb.multibox_open(boxed, sk) |
158 | 158 … | if(msg) return JSON.parse(''+msg) |
159 | 159 … | } |
160 | 160 … | |
161 … | +exports.randomKey = function () { | |
162 … | + var b = new Buffer(32) | |
163 … | + sodium.randombytes(b, 32) | |
164 … | + return b.toString('base64') | |
165 … | +} |
Built with git-ssb-web