AWS KMS提供了用于加密和解密数据的API。在加密数据时,如果使用相同的密钥和相同的明文,AWS KMS将为每个请求生成相同的密文。
示例代码:
import boto3
kms = boto3.client('kms')
plaintext = b'some plaintext'
key_id = 'alias/my-key-alias'
ciphertext = kms.encrypt(KeyId=key_id, Plaintext=plaintext)['CiphertextBlob']
decrypted_plaintext = kms.decrypt(CiphertextBlob=ciphertext)['Plaintext']