Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
MQTT-SAPTS-4005/myfile.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
70 lines (48 sloc)
1.69 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib # this allow me to hash my location | |
# MD5 x3 then sha256 this a salt. | |
def salt(password=None): # this is the registration subroutine | |
if password == None: return False | |
try: | |
password = str(password) | |
except: | |
print("error") | |
return False | |
hash_password = hashlib.md5(password.encode()) | |
Temp_hash = hash_password.hexdigest() | |
hash_pt2 = hashlib.md5(Temp_hash.encode()) | |
Temp_hash = hash_pt2.hexdigest() | |
hash_pt3 = hashlib.md5(Temp_hash.encode()) | |
Temp_hash = hash_pt3.hexdigest() | |
hash_pt4 = hashlib.sha256(Temp_hash.encode()) | |
Final_hash = hash_pt4.hexdigest() | |
return Final_hash | |
print(salt()) | |
def decrypt(lat,long): | |
# lat = lat_value + salt(lat_Value) | |
# long = long_value + salt(long_value) | |
split_lat = lat.split('#') # need 1st value | |
split_long = long.split('#') # need 2nd value | |
lat_value = split_lat[0] | |
long_value = split_long[1] | |
lat_salted = salt(split_lat[0]) | |
long_salted = salt(split_long[1]) | |
print("Hello") | |
print(lat_value,long_value) | |
lat_string = f"{lat_value}#{lat_salted}" | |
long_string = f"{long_salted}#{long_value}" | |
print(lat_string) | |
if lat_string == lat and long_string == long: | |
print("Match! ") | |
return lat_value,long_value | |
print("Error decryption") | |
return False,False | |
''' | |
import random | |
latitude = (random.randint(0, 100)) | |
longitude = (random.randint(0, 180)) | |
print(latitude, longitude) | |
new_lat = f"{latitude}#{salt(latitude)}" | |
new_log = f"{salt(longitude)}#{longitude}" | |
print(new_lat,new_log) | |
print( decrypt( new_lat,new_log)) | |
''' |