Hash list of cell text in Google Sheets

How can I calculate the hash code of MD5 or SHA1 in a list of cells? For example, I have 100 email addresses in column A row 1-100, and I want to encrypt them. I would like to write encrypted letters in column B next to each decrypted email address. What is the best way to do this?

I read the answer here , but it definitely doesn't work

I have minimal experience with Google spreadsheets: - (

I started by using this script, but could only encrypt one email at a time

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;
}
+4
source share
2 answers

, straightToText(),

function straightToText() {
  var ss = SpreadsheetApp.getActiveSpreadsheet().getSheets();
  var r = 1;
  var n_rows = 9999;
  var n_cols = 1;
  var column = 1;
  var sheet = ss[0].getRange(r, column, n_rows, ncols).getValues(); // get first sheet, a1:a9999
  var results = [];
  for (var i = 0; i < sheet.length; i++) {
    var hashmd5= GetMD5Hash(sheet[i][0]);
    results.push(hashmd5);
  }
  var dest_col = 3;
  for (var j = 0; j < results.length; j++) {
    var row = j+1;
    ss[0].getRange(row, dest_col).setValue(results[j]);  // write output to c1:c9999 as text
  }  
}
0

MD5, , B1 :

=arrayformula(MD5(A1:A100))
+2

All Articles