/usr/lib/python2.7/dist-packages/acix/core/hashes.py is in nordugrid-arc-acix-core 5.4.2-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | #
#**************************************************************************
#* *
#* General Purpose Hash Function Algorithms Library *
#* *
#* Author: Arash Partow - 2002 *
#* URL: http://www.partow.net *
#* URL: http://www.partow.net/programming/hashfunctions/index.html *
#* *
#* Modified by Henrik Thostrup Jensen <htj@ndgf.org> to operate on int *
#* arrays instead of strings (large optimization when performing several *
#* hashes of the same string. (2009) *
#* *
#* Copyright notice: *
#* Free use of the General Purpose Hash Function Algorithms Library is *
#* permitted under the guidelines and in accordance with the most current *
#* version of the Common Public License. *
#* http://www.opensource.org/licenses/cpl.php *
#* *
#**************************************************************************
#
def RSHash(key):
a = 378551
b = 63689
hash = 0
for k in key:
hash = hash * a + k
a = a * b
return hash
def JSHash(key):
hash = 1315423911
for k in key:
hash ^= ((hash << 5) + k + (hash >> 2))
return hash
def PJWHash(key):
BitsInUnsignedInt = 4 * 8
ThreeQuarters = long((BitsInUnsignedInt * 3) / 4)
OneEighth = long(BitsInUnsignedInt / 8)
HighBits = (0xFFFFFFFF) << (BitsInUnsignedInt - OneEighth)
hash = 0
test = 0
for k in key:
hash = (hash << OneEighth) + k
test = hash & HighBits
if test != 0:
hash = (( hash ^ (test >> ThreeQuarters)) & (~HighBits));
return (hash & 0x7FFFFFFF)
def ELFHash(key):
hash = 0
x = 0
for k in key:
hash = (hash << 4) + k
x = hash & 0xF0000000
if x != 0:
hash ^= (x >> 24)
hash &= ~x
return hash
def BKDRHash(key):
seed = 131 # 31 131 1313 13131 131313 etc..
hash = 0
for k in key:
hash = (hash * seed) + k
return hash
def SDBMHash(key):
hash = 0
for k in key:
hash = k + (hash << 6) + (hash << 16) - hash;
return hash
def DJBHash(key):
hash = 5381
for k in key:
hash = ((hash << 5) + hash) + k
return hash
def DEKHash(key):
hash = len(key);
for k in key:
hash = ((hash << 5) ^ (hash >> 27)) ^ k
return hash
def BPHash(key):
hash = 0
for k in key:
hash = hash << 7 ^ k
return hash
def FNVHash(key):
fnv_prime = 0x811C9DC5
hash = 0
for k in key:
hash *= fnv_prime
hash ^= k
return hash
## requres index, so we don't use it
#def APHash(key):
# hash = 0xAAAAAAAA
# for k in key:
# if ((i & 1) == 0):
# hash ^= ((hash << 7) ^ k * (hash >> 3))
# else:
# hash ^= (~((hash << 11) + k ^ (hash >> 5)))
# return hash
|