Created
April 14, 2020 12:09
-
-
Save nihalpasham/7695d584426ea86922aa8e7055e6ea8c to your computer and use it in GitHub Desktop.
token generation
This file contains hidden or 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
real_tokens = [] | |
imag_tokens = [] | |
for i in range(0, len(symbols_real)): | |
if symbols_real[i] == 15: | |
token = symbols_real[i:i+9] | |
checksum = np.sum(token) % 16 | |
if checksum <= 4 or checksum >= 13 : | |
q = (''.join([format(symbol, 'x') for symbol in token[1:7]])) | |
# print(q) | |
# print(int(q, 16)) | |
real_tokens.append(int(q, 16)) | |
for i in range(0, len(symbols_imag)): | |
if symbols_imag[i] == 15: | |
token = symbols_imag[i:i+9] | |
checksum = np.sum(token) % 16 | |
if checksum <= 4 or checksum >= 13 : | |
q = (''.join([format(symbol, 'x') for symbol in token[1:7]])) | |
# print(q) | |
# print(int(q, 16)) | |
imag_tokens.append(int(q, 16)) | |
def remove_duplicates(token_list): | |
final_list = [] | |
for num in token_list: | |
if num not in final_list: | |
final_list.append(num) | |
return final_list | |
print(remove_duplicates(real_tokens)) | |
print(remove_duplicates(imag_tokens)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment