You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/*** Compute a hash string using the specified digest algorithm on the specified value.* @param {String} value The specified value.* @param {String} digestAlgorithm The name of Enum DigestAlgorithm: MD2, MD5, SHA_1, SHA_256, SHA_384, SHA_512* @param {String} charset The name of Enum Charset: US_ASCII, UTF_8.* @returns {String} The hash of value.*/functionhash_(str,digestAlgorithm,charset){charset=charset||Utilities.Charset.UTF_8;digestAlgorithm=digestAlgorithm||'MD5';vardigest=Utilities.computeDigest(Utilities.DigestAlgorithm[digestAlgorithm],str,charset);var__='';for(i=0;i<digest.length;i++){varbyte=digest[i];if(byte<0)byte+=256;varbStr=byte.toString(16);if(bStr.length==1)bStr='0'+bStr;__+=bStr;}return__;}
Testing
/* Testing by GasT https://github.com/zixia/gast*/functiontest(){if((typeofGasTap)==='undefined'){// GasT Initialization. (only if not initialized yet.)varcs=CacheService.getScriptCache().get('gast');if(!cs){cs=UrlFetchApp.fetch('https://raw.githubusercontent.com/zixia/gast/master/src/gas-tap-lib.js').getContentText();CacheService.getScriptCache().put('gast',cs,21600);}eval(cs);}// Class GasTap is ready for use now!vartest=newGasTap();test('Md5',function(t){vari=hash_('');t.equal(i,'d41d8cd98f00b204e9800998ecf8427e','"" is d41d8cd98f00b204e9800998ecf8427e')});test('Md5',function(t){vari=hash_('test','MD5');t.equal(i,'098f6bcd4621d373cade4e832627b4f6','"" is 098f6bcd4621d373cade4e832627b4f6')});test('Md2',function(t){vari=hash_('test','MD2');t.equal(i,'dd34716876364a02d0195e2fb9ae2d1b','"" is dd34716876364a02d0195e2fb9ae2d1b')});test('SHA_1',function(t){vari=hash_('test','SHA_1');t.equal(i,'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3','"" is a94a8fe5ccb19ba61c4c0873d391e987982fbbd3')});test('SHA_256',function(t){vari=hash_('test','SHA_256');t.equal(i,'9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08','"" is 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08')});test('SHA_384',function(t){vari=hash_('test','SHA_384');t.equal(i,'768412320f7b0aa5812fce428dc4706b3cae50e02a64caa16a782249bfe8efc4b7ef1ccb126255d196047dfedf17a0a9','"" is 768412320f7b0aa5812fce428dc4706b3cae50e02a64caa16a782249bfe8efc4b7ef1ccb126255d196047dfedf17a0a9')});test('SHA_512',function(t){vari=hash_('test','SHA_512');t.equal(i,'ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff','"" is ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff')});test.finish()}
The text was updated successfully, but these errors were encountered:
Target
Snippet
Testing
The text was updated successfully, but these errors were encountered: