diff --git a/hash2phone/hashmap_gen.py b/hash2phone/hashmap_gen.py index 45e552b..acce756 100644 --- a/hash2phone/hashmap_gen.py +++ b/hash2phone/hashmap_gen.py @@ -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() @@ -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) @@ -52,4 +55,3 @@ connection.commit() print("last num:\t", strnum) print("done!") - diff --git a/hash2phone/map_hash_num_sqlite.php b/hash2phone/map_hash_num_sqlite.php new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/hash2phone/map_hash_num_sqlite.php @@ -0,0 +1 @@ +