1

Can anyone help me understand what the following means please?

Exception: The parameters don't match the method signature for Utilities.computeDigest.

I'm trying to run a script that hashes filenames in my Google drive, but I keep getting the above error and I can't seem to find info about it.

The corresponding line of code is:

var fileHash = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, file);

Thanks

player0
  • 124,011
  • 12
  • 67
  • 124
Karlan Shum
  • 19
  • 1
  • 2
  • 3
    Is your second parameter (file) a String or a byte? [In the documentation](https://developers.google.com/apps-script/reference/utilities/utilities#computedigestalgorithm,-value) it mentions that the second parameter must be of type String or Byte[]. [Here is an example of the latest](https://developers.google.com/apps-script/reference/utilities/utilities#computedigestalgorithm,-value) – Mateo Randwolf Feb 24 '20 at 09:26

1 Answers1

2

As Mateo Randwolf in a comment said:

Is your second parameter (file) a String or a byte? In the documentation it mentions that the second parameter must be of type String or Byte[]

For my case, the solution was to convert it into string:

var str = '' + file;
var fileHash = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, str);

Ref:

https://developers.google.com/apps-script/reference/utilities/utilities#computedigestalgorithm,-value,-charset

Max Makhrov
  • 17,309
  • 5
  • 55
  • 81