Skip to content

Commit

Permalink
Update hashmap_gen.py
Browse files Browse the repository at this point in the history
Old version had multiple failures, this should fix it, but it breaks the percent complete.
  • Loading branch information
CaptainStabs authored Oct 22, 2019
1 parent d9ecb3b commit 25dd141
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions hash2phone/hashmap_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
if len(sys.argv)!=2:
print("\nUsage:\t",sys.argv[0],"<4-digit phone prefix>")
print("\nEx.:Calculate hashmap for range +12130000000 -- +12139999999:")
print(sys.argv[0],"1213")
print(sys.argv[0],"1213")
print("\n\n");
sys.exit()

Expand All @@ -38,12 +38,15 @@
if num % 100000 == 0:
print(100-(stop_num-num)/100000,"% complete")
connection.commit()
strnum = str(num)
strnum = str(num).encode('utf-8')
m = hashlib.sha256()
m.update(strnum)
hash= m.digest().encode("hex")[0:6]

record_to_insert = ("\\x"+hash, strnum)
bhash = m.digest()
strhash = str(bhash).encode()
print(strhash)
print(strnum)
record_to_insert = (strhash, num)
print(record_to_insert)
cursor.execute(postgres_insert_query, record_to_insert)


Expand All @@ -52,4 +55,3 @@
connection.commit()
print("last num:\t", strnum)
print("done!")

0 comments on commit 25dd141

Please sign in to comment.