Generate burn after reading link for pads

This commit is contained in:
yflory
2020-01-09 15:16:07 +01:00
parent 14905a5693
commit 96a00f89df
6 changed files with 220 additions and 93 deletions

View File

@@ -16,15 +16,16 @@ var factory = function (Util, Crypto, Nacl) {
};
// XXX move this code?
Hash.generateSignPair = function (safe) {
Hash.generateSignPair = function () {
var ed = Nacl.sign.keyPair();
var makeSafe = function (key) {
if (!safe) { return key; }
return Crypto.b64RemoveSlashes(key).replace(/=+$/g, '');
};
return {
validateKey: makeSafe(encode64(ed.publicKey)),
signKey: makeSafe(encode64(ed.secretKey)),
validateKey: Hash.encodeBase64(ed.publicKey),
signKey: Hash.encodeBase64(ed.secretKey),
safeValidateKey: makeSafe(Hash.encodeBase64(ed.publicKey)),
safeSignKey: makeSafe(Hash.encodeBase64(ed.secretKey)),
};
};