The default paths are defined in the BIP specs, but some wallets may use different ones due to an error or intentionally (for instance, Ledger's Vertcoin derivation uses Monero's derivation path due to a coding error).You can use tools such as (preferably offline) to play around with your seed and derivation paths until you see your addresses. Generate bitcoin address from private key. Mnemonic seeds are based on the BIP39 (seeds) and (accounts/multiple currencies).When deriving addresses, one uses a derivation path to get to a specific addresses.
an example of symmetric encryption in python using a single known secret key - utilizes AES from PyCrypto library
I have two systems which need to encrypt their communication by AES-128. The key for the AES encryption should be exchanged with the Diffie-Hellman (DH) algorithm. Call of duty cd key generator. Now, I've read about DH and got a lot of question marks over my head. These are my questions: Typically with AES-128, you need a password and a key which will be generated from the.
AES-128 has 128 bit key = 16 bytes. Randomkey = os.urandom(16) should be sufficient for most uses. When you feed this random value to M2 (or whatever crypto library), it is transformed internally into a 'key schedule' actually used for encryption. I want to combine hashing and encryption for better security. So can I use a hash key generated from SHA-512 as a key in AES. For example, I have a password 'secret', I calculate SHA-512 hash for. Assuming I have a server/client topology, currently I'm facing the problem that I want to generate some key on the client side and somehow make the remote server get it securely. I'm using AES on both parts, so basically what I need is to generate a random IV and a random secret key, but how to share it with the server so it can afterward decrypt the messages?
AES_example.py
# Inspired from https://pythonprogramming.net/encryption-and-decryption-in-python-code-example-with-explanation/ |
# PyCrypto docs available at https://www.dlitz.net/software/pycrypto/api/2.6/ |
fromCrypto.CipherimportAES |
importbase64, os |
defgenerate_secret_key_for_AES_cipher(): |
# AES key length must be either 16, 24, or 32 bytes long |
AES_key_length=16# use larger value in production |
# generate a random secret key with the decided key length |
# this secret key will be used to create AES cipher for encryption/decryption |
secret_key=os.urandom(AES_key_length) |
# encode this secret key for storing safely in database |
encoded_secret_key=base64.b64encode(secret_key) |
returnencoded_secret_key |
defencrypt_message(private_msg, encoded_secret_key, padding_character): |
# decode the encoded secret key |
secret_key=base64.b64decode(encoded_secret_key) |
# use the decoded secret key to create a AES cipher |
cipher=AES.new(secret_key) |
# pad the private_msg |
# because AES encryption requires the length of the msg to be a multiple of 16 |
padded_private_msg=private_msg+ (padding_character* ((16-len(private_msg)) %16)) |
# use the cipher to encrypt the padded message |
encrypted_msg=cipher.encrypt(padded_private_msg) |
# encode the encrypted msg for storing safely in the database |
encoded_encrypted_msg=base64.b64encode(encrypted_msg) |
# return encoded encrypted message |
returnencoded_encrypted_msg |
defdecrypt_message(encoded_encrypted_msg, encoded_secret_key, padding_character): |
# decode the encoded encrypted message and encoded secret key |
secret_key=base64.b64decode(encoded_secret_key) |
encrypted_msg=base64.b64decode(encoded_encrypted_msg) |
# use the decoded secret key to create a AES cipher |
cipher=AES.new(secret_key) |
# use the cipher to decrypt the encrypted message |
decrypted_msg=cipher.decrypt(encrypted_msg) |
# unpad the encrypted message |
unpadded_private_msg=decrypted_msg.rstrip(padding_character) |
# return a decrypted original private message |
returnunpadded_private_msg |
####### BEGIN HERE ####### |
private_msg='' |
Lorem ipsum dolor sit amet, malis recteque posidonium ea sit, te vis meliore verterem. Duis movet comprehensam eam ex, te mea possim luptatum gloriatur. Modus summo epicuri eu nec. Ex placerat complectitur eos. |
'' |
padding_character='{' |
secret_key=generate_secret_key_for_AES_cipher() |
encrypted_msg=encrypt_message(private_msg, secret_key, padding_character) |
decrypted_msg=decrypt_message(encrypted_msg, secret_key, padding_character) |
print' Secret Key: %s - (%d)'% (secret_key, len(secret_key)) |
print'Encrypted Msg: %s - (%d)'% (encrypted_msg, len(encrypted_msg)) |
print'Decrypted Msg: %s - (%d)'% (decrypted_msg, len(decrypted_msg)) |
commented Jan 18, 2019 • edited
edited
Aes Python Code
See also https://gist.github.com/btoueg/f71b62f456550da42ea9f4a4bd907d21 for an example using cryptography |
Aes Key Generator
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment