Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 4444 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

Anyone know if it is possible to generate sha256 encrypted text using Scriptmaster?

 

any response is highly appreciated.

Posted

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() );

Posted

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.

  • Like 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.