job.answiz.com
  • 1
Votes
name
name Punditsdkoslkdosdkoskdo

Hash of a cell text in Google Spreadsheet

How can I compute a MD5 or SHA1 hash of text in a specific cell and set it to another cell in Google Spreadsheet?

Is there a formula like =ComputeMD5(A1) or =ComputeSHA1(A1)?

Or is it possible to write custom formula for this? How?

Open Tools > Script Editor then paste the following code:

function MD5 (input) {
  var rawHash = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, input);
  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;
}

Save the script after that and then use the MD5() function in your spreadsheet while referencing a cell.

This script is based on Utilities.computeDigest() function.

  • 0
Reply Report


Qries

Related Questions

Trending Tags