Skip to content

Instantly share code, notes, and snippets.

@huschdie
Created July 24, 2016 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save huschdie/64dac2cf536088a592faaa1733773440 to your computer and use it in GitHub Desktop.
Save huschdie/64dac2cf536088a592faaa1733773440 to your computer and use it in GitHub Desktop.
Code text to md5
function to_md5(text_to_md5) {
var toMD5 = text_to_md5 //md5sheet.getRange('b9').getValue()
var signature = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, toMD5, Utilities.Charset.US_ASCII);
var signatureStr = '';
for (i = 0; i < signature.length; i++) {
var byte = signature[i];
if (byte < 0)
byte += 256;
var byteStr = byte.toString(16);
// Ensure we have 2 chars in our byte, pad with 0
if (byteStr.length == 1) byteStr = '0'+byteStr;
signatureStr += byteStr;
}
return signatureStr
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment