Examining the script objects
When you open one of the two provided samples in AEM Forms on JEE Designer, you find the four script objects in the Hierarchy palette (see Figure below).
To see the JavaScript implementation of the hash functions within these script objects, select the script object and explore the code in the Script Editor. You can see how each of the following hash functions has been implemented:
- soHASHING_MD4.hex_md4()
- soHASHING_MD4.b64_md4()
- soHASHING_MD4.str_md4()
- soHASHING_MD5.hex_md5()
- soHASHING_MD5.b64_md5()
- soHASHING_MD5.str_md5()
- soHASHING_SHA1.hex_sha1()
- soHASHING_SHA1.b64_sha1( )
- soHASHING_SHA1.str_sha1( )
- soHASHING_SHA256.hex_sha256()
- soHASHING_SHA256.b64_sha256()
- soHASHING_SHA256.str_sha256()
As you can see from this list, there are different functions available for the different output types of the hash. You can choose between hex_
for hexadecimal digits, b64_
for Base64 encoded output, or str_
for simple string encoding.
Depending on the hash function you choose, the length of the hash varies:
- MD4: 128 bits
- MD5: 128 bits
- SHA-1: 160 bits
- SHA-256: 256 bits
Trying the sample PDF forms
The sample files for this article include two PDF forms. The first sample lets you type in a string and then generate MD4, MD5, SHA-1, and SHA-256 hash values for the string. The second sample is a simple form that unlocks text fields if a correct password is entered.