def get_uid(): interfaces = netifaces.interfaces() interfaces.sort() i = interfaces[0] s = "abcdefghijklmnopqrstuvwxyz" u = "ABCDEFGHJKLMNPQRSTUVWXYZ" d = "0123456789" bc = BaseConverter(d+s+u) hashid = hashlib.sha1(i.encode("utf-8")).hexdigest() hashid = hashid.upper() raw = base16.decode(hashid) uid = bc.encode(raw) return uid
def main(): HOW_TO = """Just copy stuff to clipboard and check console!""" print(PROGRAM_NAME + " " + "greets you!") print("How to:") print(HOW_TO) recent_value = "" # print for user print(PROGRAM_NAME + " is up & running") print("") try: while True: tmp_value = pyperclip.paste() if tmp_value != recent_value: raw = tmp_value #find_between(tmp_value, "MoodleSessionLMS2=", "; path=/") if (len(raw)): what_to_log = "[+] Input: " + raw print(what_to_log) ret = "" try: b02 = ASCII_base.encode(base2.decode(raw)) ret += "base02: " + b02 + "\n" except Exception: pass try: b16 = ASCII_base.encode(base16.decode(raw)) ret += "base16: " + b16 + "\n" except Exception: pass try: b36 = ASCII_base.encode(base36.decode(raw)) ret += "base36: " + b36 + "\n" except Exception: pass try: b56 = ASCII_base.encode(base56.decode(raw)) ret += "base56: " + b56 + "\n" except Exception: pass try: b58 = ASCII_base.encode(base58.decode(raw)) ret += "base58: " + b58 + "\n" except Exception: pass try: b62 = ASCII_base.encode(base62.decode(raw)) ret += "base62: " + b62 + "\n" except Exception: pass try: b64 = ASCII_base.encode(base64.decode(raw)) ret += "base64: " + b64 + "\n" except Exception: pass try: flask = FSCM.decode(str(raw), None) ret += "Flask: " + flask + "\n" except Exception: pass what_to_log = ret print(what_to_log) else: what_to_log = "[-] New paste, but no raw detected :(" print(what_to_log) recent_value = tmp_value time.sleep(0.1) except KeyboardInterrupt: print('cya!')
# latest_fin_eth_blk_num = int(requests.get(base_url).json()['height']) - 12 # r = requests.get(base_url + '/blocks/' + str(latest_fin_eth_blk_num)).json() # msg = bytes(str(r['hash']) +'_'+ str(r['time']), 'utf-8') msg = b'fe895898b8064515820af15e1921f8b5ae3c1660bb5dfd63bc07c04ce236972b_2018-12-16T17:36:36Z' # 3. Sign msg with pk sig = pk.sign_msg(msg) # Stegano's jpg support is broken. img = Image.open("sample.jpg") img.save("sample.png") del img # 4. encode sig into img # there has got to be an easier way... secret_sig = base56.encode(base16.decode(sig.to_hex()[2:].upper())) vessel_img = lsbset.hide("sample.png", secret_sig, generators.eratosthenes()) vessel_img.save("sig0.png") # 5. Hash vessel_img vih = sha3.keccak_256(vessel_img.tobytes()).digest() '''VERIFICATION EXAMPLE''' # 4. Prover provides verifer with secret_sig and generator used, verifer extracts secret_sig revealed_sig = lsbset.reveal("sig0.png", generators.eratosthenes()) # "sanity" check # base16.encode(base56.decode(revealed_sig)).lower() == sig.to_hex()[2:] # Convert back into a eth_key Signature rsig = keys.Signature(bytes.fromhex(base16.encode(base56.decode(revealed_sig))))
def encode_to_base62(obj_id): ''' First decodes the hexadecimal object ID and then encodes it to base 62 which will be used as the short URL ID ''' return base62.encode(base16.decode(str(obj_id).upper()))
def keccakmod(s): rawhash = hashlib.sha3_224(s.encode('utf-8')).hexdigest().upper() modhash = base62.encode(base16.decode(rawhash)) return modhash