Best Python code snippet using localstack_python
CreateKeyPairsApp.py
Source:CreateKeyPairsApp.py
...18 key_id = "mrk-2bf0b98efa5e45d286a8ef19bf87f60a"19 20 #request to create keys21 #RSA for encryption/decryption22 rsa_response = kms_client.generate_data_key_pair(23 KeyId=key_id,24 KeyPairSpec= 'RSA_4096',25 )26 27 #Request for ECC SIGNING28 ecc_response = kms_client.generate_data_key_pair(29 KeyId = key_id,30 KeyPairSpec = "ECC_NIST_P521"31 )32 33 '''34 PrivateKeyCiphertextBlob35 PrivateKeyPlaintext36 PublicKey37 KeyId38 KeyPairSpec = RSA_4096 or ECC_NIST_P52139 ResponseMetadata40 '''4142 #ignore these
...
create_key_pairs_app.py
Source:create_key_pairs_app.py
...19 key_id = "mrk-2bf0b98efa5e45d286a8ef19bf87f60a"20 21 #request to create keys22 #RSA for encryption/decryption23 rsa_response = kms_client.generate_data_key_pair(24 KeyId=key_id,25 KeyPairSpec= 'RSA_4096',26 )27 28 #Request for ECC SIGNING29 ecc_response = kms_client.generate_data_key_pair(30 KeyId = key_id,31 KeyPairSpec = "ECC_NIST_P521"32 )33 34 '''35 response36 PrivateKeyCiphertextBlob37 PrivateKeyPlaintext38 PublicKey39 KeyId40 KeyPairSpec = RSA_4096 or ECC_NIST_P52141 ResponseMetadata42 '''43 #KEEP NOTE PRIVATE KEY IS ENCRYPTED!...
load_keys.py
Source:load_keys.py
2import base643import uuid4import sys5def store_key(table, key):6 key_pair = kms_client.generate_data_key_pair(KeyId=key, KeyPairSpec='RSA_2048')7 table.put_item(Item={8 "master_key_id": key_pair["KeyId"],9 "key_id": str(uuid.uuid4()),10 "private_key_ciphertext_blob": base64.b64encode(key_pair["PrivateKeyCiphertextBlob"]).decode(),11 "public_key": base64.b64encode(key_pair["PublicKey"]).decode(),12 "enabled": True13 })14if __name__ == '__main__':15 master_key = sys.argv[1]16 tableName = sys.argv[2]17 kms_client = boto3.client("kms")18 dynamodb = boto3.resource('dynamodb')19 table = dynamodb.Table(tableName)20 store_key(table, master_key)
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!