@burstjs/crypto
Advanced tools
Comparing version 0.4.3 to 0.5.0-0.5.0-beta.1.0
@@ -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.4.3", | ||
"version": "0.5.0-0.5.0-beta.1.0", | ||
"description": "Cryptographic functions for building Burstcoin apps.", | ||
@@ -60,3 +60,3 @@ "contributors": [ | ||
}, | ||
"gitHead": "287dde637cda6bfde1252978c4730d3f96cafef8", | ||
"gitHead": "19a030e2278c21ff762c927ef1fb7daad330a6a1", | ||
"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
1823081
119
20856