the
hash
of
data
the
hash
of
(
data ,
algorithm )
hash
(
data ,
algorithm )
Data yields a binary
or a string
. Algorithm yields the name of a hash algorithm.
put hash(steve, "Atkinson") into bill
put hash(data, "MD5") into md5
The hash
function hashes the specified data with the specified hash algorithm and returns an integer
, a binary
, or a string
containing the resulting hash.
If data is not a binary
, it is converted to a string
, converted to lowercase, and then converted to a binary
using the text encoding specified by the textEncoding
property.
If the hash algorithm is not specified, the default is the Atkinson hash algorithm. The Atkinson algorithm is the only hash algorithm required by the XION Scripting Language Standard. The resulting hash is returned as an unsigned integer
. The Atkinson hash algorithm is as follows:
if the binary is zero-length:
initialize hash to 0x42696C6C
('Bill'
)
else:
initialize hash to zero
initialize seed to the unsigned value of the first byte, plus the number of bytes
for each bit b in the binary, starting with the most significant bit of the first byte:
multiply seed by 0x41A7
while seed ≥ 0x80000000
:
set seed to ( seed & 0x7FFFFFFF
) + ( seed >> 31 )
if seed = 0x7FFFFFFF
:
set seed to zero
if bit b is set:
add seed to hash
return the 32 least significant bits of hash
OpenXION supports Atkinson, returning an unsigned integer
, as well as MD2, MD5, SHA-1, SHA-256, SHA-384, and SHA-512, returning a binary
.