GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Calculate SHA-1 of a String (for use in a script function)


#1

What's a decent way to do this in a script (i.e. minimizing external dependencies)?


How to use FSUtil.Hash on a string (JScript)?
#2

You could write the string to a temp file and then use FSUtil.Hash on it. No external dependencies needed at all for that.


#3

In the next update we'll make it so you can hash a string or other data without having to write it to disk first.


#4

Could I, by any chance, get a quick example usage (since the latest beta is out :smile:)?


#5

Figured it out:

var b = DOpus.Create.Blob();
b.copyFrom('I want to be hashed!');
var hash = DOpus.FSUtil().Hash(b, 'sha1');