Hash Functions(4.3)
Use the functions below to turn bytearray input of arbitrary length into an output of fixed length
hashDigest
Completes the hash computation by performing final operations such as padding. After this call is made the digest is reset.
bytearray hashDigest();
Parameter | Description |
---|---|
Returns | A hexadecimal hash sum |
hashReset
Resets the digest for further use.
void hashReset();
Parameter | Description |
---|---|
Returns | Nothing |
hashUpdate
Updates the digest using the specified array of bytes.
void hashUpdate(bytearray);
Parameter | Description |
---|---|
| Any type of bytearray |
Returns | Nothing |
hashSetAlgorithm
Uses a digest that implements the specified digest algorithm.
Note!
The default setting, that is if the algorithm is not set, the SHA-1 hash method is used.
void hashSetAlgorithm(<"hash_method">);
Parameter | Description |
---|---|
| The name of the algorithm requested. Supported hash algorithms are: MD2, MD5, SHA-1, SHA-256, SHA-384, SHA-512 |
Returns | Nothing. |
hashSetAlgorithmFromProvider
Uses a digest that implements the specified digest algorithm, as supplied from the specified provider. The digest will be reset.
void hashSetAlgorithmFromProvider(string,string);
Parameter | Description |
---|---|
| The name of the hash algorithm developed by the provider |
| The name of the provider |
Returns | Nothing |
Hash Example
Example - Hash
initialize { hashSetAlgorithm("MD2"); } beginBatch { hashReset(); } consume { hashUpdate(input); } drain { bytearray hashsum = hashDigest(); string sHashSum = baToHexString(hashsum); // Optional bytearray result; // Optional strToBA(result, sHashSum); // Optional udrRoute(result); }
Note!
The optional parts in the example are added to convert the hash sum to a more readable form.