Newbies sky2k Posted November 27, 2012 Newbies Posted November 27, 2012 Anyone know if it is possible to generate sha256 encrypted text using Scriptmaster? any response is highly appreciated.
Karsten Wolf Posted November 27, 2012 Posted November 27, 2012 Try this. It takes the path to a file as a parameter and outputs the SHA-256 as a hexstring. function: sha256 parameters: filepath // path to file for which the digest will be created import java.io.FileInputStream; import java.security.MessageDigest; import java.security.DigestInputStream // MessageDigest md = MessageDigest.getInstance("MD5"); // MessageDigest md = MessageDigest.getInstance("SHA-512"); MessageDigest md = MessageDigest.getInstance("SHA-256"); InputStream is = new FileInputStream( filepath ); try { is = new DigestInputStream(is, md); // read stream to EOF as normal... } finally { is.close(); } // for hex output return new BigInteger(1,md.digest()).toString(16).padLeft(64, '0') // for base 64 output (allows for SHA-512 in a FMP Textfield fully indexed) // return new sun.misc.BASE64Encoder().encode( md.digest() );
Karsten Wolf Posted November 30, 2012 Posted November 30, 2012 Re-reading this thread I stumbled upon the use of the word encryption. To be clear: SHA1, SHA224, SHA256, SHA384, SHA512 and MD5 are about checksums and not about encryption! They are called "secure hash" or with the older term "message digest". You use them to create tamper proof checksums of content. For example, I use SHA-512 to find identical pictures. FileMaker can't compare container fields but it can find identical entries in text fields. A hex encoded SHA-384 or a base64 encoded SHA-512 fit neatly in FMs 100 character index limit. 1
Recommended Posts
This topic is 4444 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now