Я хочу сделать последние 40 символов того, что находится внутри индекса, именем индекса, чтобы я мог получить доступ ко всем индексам, введя последние 40 символов из них, которые я знаю. Мой код на данный момент:
Код: Выделить всё
from eth_keys import keys
def generate_key_pair(index):
# Generate the private key from the index
private_key = hex(index)[2:].zfill(64) # Convert index to hexadecimal
# Generate the corresponding wallet address
private_key_bytes = bytes.fromhex(private_key)
wallet_address = keys.PrivateKey(private_key_bytes).public_key.to_checksum_address()
return private_key, wallet_address
def combine_strings(private_key, wallet_address):
# Combine private key and wallet address into a single string
combined_string = private_key + wallet_address
return combined_string
def main():
index = 1
private_key, wallet_address = generate_key_pair(index)
combined_string = combine_strings(private_key, wallet_address)
print("Combined string:", combined_string)
if __name__ == "__main__":
main()
Изменить< /p>
Кто-то сказал, что я могу пользоваться словарем. Может кто-нибудь показать мне, как я могу это сделать. Я не хочу, чтобы значения хранились в Python. Я хочу, чтобы они хранились «на лету», как в индексе, где я могу перейти к индексу, и данные будут там.
Подробнее здесь: https://stackoverflow.com/questions/784 ... f-a-number