Skip to content

Commit

Permalink
Merge pull request #26 from CaptainStabs/patch-3
Browse files Browse the repository at this point in the history
Update hashmap_gen.py
  • Loading branch information
hexway committed Jan 17, 2020
2 parents c534de7 + 283d54d commit 1f80229
Show file tree
Hide file tree
Showing 2 changed files with 9 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!")

1 change: 1 addition & 0 deletions hash2phone/map_hash_num_sqlite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 1f80229

Please sign in to comment.