/ cloudformation-templates / node_modules / aws-cdk / node_modules / aws-sdk / lib / browserCryptoLib.js
browserCryptoLib.js
1 var Hmac = require('./browserHmac'); 2 var Md5 = require('./browserMd5'); 3 var Sha1 = require('./browserSha1'); 4 var Sha256 = require('./browserSha256'); 5 6 /** 7 * @api private 8 */ 9 module.exports = exports = { 10 createHash: function createHash(alg) { 11 alg = alg.toLowerCase(); 12 if (alg === 'md5') { 13 return new Md5(); 14 } else if (alg === 'sha256') { 15 return new Sha256(); 16 } else if (alg === 'sha1') { 17 return new Sha1(); 18 } 19 20 throw new Error('Hash algorithm ' + alg + ' is not supported in the browser SDK'); 21 }, 22 createHmac: function createHmac(alg, key) { 23 alg = alg.toLowerCase(); 24 if (alg === 'md5') { 25 return new Hmac(Md5, key); 26 } else if (alg === 'sha256') { 27 return new Hmac(Sha256, key); 28 } else if (alg === 'sha1') { 29 return new Hmac(Sha1, key); 30 } 31 32 throw new Error('HMAC algorithm ' + alg + ' is not supported in the browser SDK'); 33 }, 34 createSign: function() { 35 throw new Error('createSign is not implemented in the browser'); 36 } 37 };