Last active
August 7, 2024 14:09
-
-
Save nyancodeid/e18acf94bfb74991472954dff5cce3b8 to your computer and use it in GitHub Desktop.
Google Apps Script SHA 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hmac_sha() { | |
var text = "I am SHA"; | |
var key = "hello"; | |
var hmacObject = Utilities.computeHmacSignature(Utilities.MacAlgorithm.HMAC_SHA_1, text, key); | |
var txtHash = ""; | |
for (i = 0; i < hmacObject.length; i++) { | |
var hashVal = hmacObject[i]; | |
if (hashVal < 0) { | |
hashVal += 256; | |
} | |
if (hashVal.toString(16).length == 1) { | |
txtHash += '0'; | |
} | |
txtHash += hashVal.toString(16); | |
} | |
Logger.log(txtHash); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function toSHA1() { | |
var text = "I am SHA Text or Something"; | |
var rawHash = Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_1, text); | |
var txtHash = ""; | |
for (i = 0; i < rawHash.length; i++) { | |
var hashVal = rawHash[i]; | |
if (hashVal < 0) { | |
hashVal += 256; | |
} | |
if (hashVal.toString(16).length == 1) { | |
txtHash += '0'; | |
} | |
txtHash += hashVal.toString(16); | |
} | |
return txtHash; | |
} |
Better : Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_1, input, Utilities.Charset.UTF_8);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
do you decryption techniques for sha?