@burstjs/crypto
Advanced tools
Comparing version 0.5.0-alpha.2 to 0.5.0-alpha.3
@@ -5,22 +5,5 @@ "use strict"; | ||
exports.decryptAES = (encryptedBase64, key) => { | ||
const encoded = encryptedBase64; | ||
let retrials = 0; | ||
while (retrials < 10) { | ||
try { | ||
const decrypted = CryptoJS.AES.decrypt(encoded, key); | ||
if (decrypted) { | ||
const str = decrypted.toString(CryptoJS.enc.Utf8); | ||
if (str.length > 0) { | ||
return str; | ||
} | ||
} | ||
} | ||
catch (e) { | ||
} | ||
finally { | ||
retrials++; | ||
} | ||
} | ||
return ''; | ||
const decrypted = CryptoJS.AES.decrypt(encryptedBase64, key); | ||
return decrypted && decrypted.toString(CryptoJS.enc.Utf8); | ||
}; | ||
//# sourceMappingURL=decryptAES.js.map |
{ | ||
"name": "@burstjs/crypto", | ||
"version": "0.5.0-alpha.2", | ||
"version": "0.5.0-alpha.3", | ||
"description": "Cryptographic functions for building Burstcoin apps.", | ||
@@ -60,3 +60,3 @@ "contributors": [ | ||
}, | ||
"gitHead": "50ee74a37a7964ce327930d7a4264ee5d9adc2e2", | ||
"gitHead": "92c2c5bf2ce352638613fe27ab1f247552d1b376", | ||
"publishConfig": { | ||
@@ -63,0 +63,0 @@ "access": "public" |
@@ -17,2 +17,13 @@ import {encryptAES} from '../encryptAES'; | ||
it('should encrypt/decrypt correctly unicode', () => { | ||
const secret = 'secret'; | ||
const Message = '\u01F6 with Unicode'; | ||
const encrypted = encryptAES(Message, secret); | ||
const decrypted = decryptAES(encrypted, secret); | ||
expect(decrypted).toBe(Message); | ||
}); | ||
it('should NOT encrypt/decrypt correctly', () => { | ||
@@ -19,0 +30,0 @@ |
@@ -12,22 +12,4 @@ /** @module crypto */ | ||
export const decryptAES = (encryptedBase64: string, key: string): string => { | ||
const encoded = encryptedBase64; | ||
// decrypt may throw an error occasionally...retrial may fix this | ||
let retrials = 0; | ||
while (retrials < 10) { | ||
try { | ||
const decrypted = CryptoJS.AES.decrypt(encoded, key); | ||
if (decrypted) { | ||
const str = decrypted.toString(CryptoJS.enc.Utf8); | ||
if (str.length > 0) { | ||
return str; | ||
} | ||
} | ||
} catch (e) { | ||
// no op | ||
} finally { | ||
retrials++; | ||
} | ||
} | ||
return ''; | ||
const decrypted = CryptoJS.AES.decrypt(encryptedBase64, key); | ||
return decrypted && decrypted.toString(CryptoJS.enc.Utf8); | ||
}; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1823074
20856