HASH

Added October 2011

xcall HASH, hashtype, key, cbkey, hash, status

HASH.SBR generates a hash code from a string of characters. 

hashtype specifies the type of hash to generate. Currently there are only two possibilities: 1=ELF, 2=DJB.  ELF is one of the most commonly used hash algorithms in the UNIX world, and is tweaked for 32 bit processors. DJB (named after its creator Dan J. Bernstein) is thought to be one of the most efficient hash algorithms and is thought to work work well on very short keys, but may be considered somewhat weaker than the ELF algorithm (i.e. more likely to generate the same hash from different keys) when it comes to avalanche and permutation.

See Also

•   DIGEST.

Parameters

Parameter

Type

I/O

Description

hashtype

Num

in

1=ELF, 2=DJB. See above

key

String

in

the source data from which the hash will be calculated. It can be any length.

cbkey

Num

in

optionally specifies the number of bytes to be considered in key. If 0, key is processed up to the first null byte or its physical length.

hash

String

out

the generated hash. If string (8+ bytes), then it will be returned as 8 hex digits. If b,4, it will be returned as a 32 bit value.

status

Signed Num

out

indicates success or failure:

>=0

success

-1

bad key type

-2

bad hash type

-3

bad has data type of size

 

History

2011 October, A-Shell 5.1.1239:  Added to A-Shell