-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_hashing.py
More file actions
29 lines (24 loc) · 861 Bytes
/
python_hashing.py
File metadata and controls
29 lines (24 loc) · 861 Bytes
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
import hashlib
# word = ACCGTACGTACGATTAGCAT
# hash_object = hashlib.md5()
# hash_object.update(str.encode(word))
# hash_object.update(b'3')
# hex_ob = hash_object.hexdigest()
# small_hash = int(hex_ob[0:7], 16)
# print(small_hash)
# hash_object = hashlib.new('DSA')
# hash_object.update(b'ACCGTACGTACGATTAGCAT')
# hash_object.update(b'2')
# hex_ob = hash_object.hexdigest()
# small_hash = int(hex_ob[0:7], 16)
# print(small_hash)
# print(2**28)
# This defines a set of hashes all based off the integer value provided.
# word should be a 20-length string in the genome
def DSA_hash(word, value):
hash_object = hashlib.new('DSA')
hash_object.update(str.encode(word + str(value)))
hex_ob = hash_object.hexdigest()
small_hash = int(hex_ob[0:7], 16)
return small_hash
# DSA_hash returns an integer value in (0, 16**7 = 2**28)