Calculates the hash value for the string.
IppStatus ippsHash_8u32u(const Ipp8u* pSrc, int len, Ipp32u* pHashVal);
IppStatus ippsHash_16u32u(const Ipp16u* pSrc, int len, Ipp32u* pHashVal);
IppStatus ippsHashSJ2_8u32u(const Ipp8u* pSrc, int len, Ipp32u* pHashVal);
IppStatus ippsHashSJ2_16u32u(const Ipp16u* pSrc, int len, Ipp32u* pHashVal);
IppStatus ippsHashMSCS_8u32u(const Ipp8u* pSrc, int len, Ipp32u* pHashVal);
IppStatus ippsHashMSCS_16u32u(const Ipp16u* pSrc, int len, Ipp32u* pHashVal);
pSrc |
Pointer to the source string. |
len |
Number of elements in the string. |
pHashVal |
Pointer to the result value. |
The function ippsHash is declared in the ippch.h file. This function produces the hash value pHasVal for the specified string pSrc. The hash value is fairly unique to the given string. If hash values of two strings are different, the strings are different as well. If the hush values are the same, the strings are probably identical. The hash value is calculated in the following manner: initial value is set to 0, then the hash value is calculated successively for each i-th string element as pHashVal[i] = 2* pHashVal[i-1]^ pSrc[i], where ^ denotes a bitwise exclusive OR (XOR) operator. The hash value for the last element is the hash value for the whole string.
Code example below shows how to use the functions ippsHash_8u32u, ippsHashSJ2_8u32u, and ippsHashMSCS_8u32u.
ippStsNoErr |
Indicates no error. |
ippStsNullPtrErr |
Indicates an error condition if one of the specified pointers is NULL. |
ippStsLengthErr |
Indicates an error condition if len is negative. |
Ipp8u string[] = "monkey";
Ipp32u hash;
hash = 0;
ippsHash_8u32u( string, sizeof (string) - 1, &hash );
printf ( "ippsHash_8u32u hash value: %u\n", hash );
hash = 0;
ippsHashSJ2_8u32u( string, sizeof (string) - 1, &hash );
printf ( "ippsHashSJ2_8u32u hash value: %u\n", hash );
hash = 0;
ippsHashMSCS_8u32u( string, sizeof (string) - 1, &hash );
printf ( "ippsHashMSCS_8u32u hash value: %u\n", hash );
Output:
ippsHash_8u32u hash value: 2367
ippsHashSJ2_8u32u hash value: 3226471379
ippsHashMSCS_8u32u hash value: 1466279646
Copyright © 2000 - 2010, Intel Corporation. All rights reserved.