用于aws的加密原语

murmuration的Python项目详细描述


杂音

Build Status 用于AWS KMS的加密原语

AES+Galois计数器模式加密

frommurmurationimportgcmkey='this is my secret encryption key'plaintext='the quick brown fox jumps over the lazy dog'ciphertext=gcm.encrypt(plaintext,key,'header')decrypted=gcm.decrypt(ciphertext,key)assertdecrypted==plaintext

使用KMS加密(用于AWS)

您还可以将kms用作加密/解密服务。这是真的 产生KMS成本并要求设置KMS。regionprofile参数 不必指定。如果未指定这些值,则 推断出in the order specified by boto3

  1. Passing credentials as parameters in the boto.client() method
  2. Passing credentials as parameters when creating a Session object
  3. Environment variables
  4. Shared credential file (~/.aws/credentials)
  5. AWS config file (~/.aws/config)
  6. Assume Role provider
  7. Boto2 config file (/etc/boto.cfg and ~/.boto)
  8. Instance metadata service on an Amazon EC2 instance that has an IAM role configured.
frommurmurationimportkmsplaintext='the quick brown fox jumps over the lazy dog'key_alias='my kms key alias'ciphertext=kms.encrypt(plaintext,key_alias,region='us-west-1',profile='company')decrypted=kms.decrypt(ciphertext,region='us-west-1',profile='company')assertdecrypted==plaintext

使用KMS包装加密(用于AWS)

您还可以使用包装的KMS数据密钥进行加密,以保护底层 KMS键。使用此Does功能将产生KMS成本并需要KMS 设置。无需指定regionprofile参数。
如果未指定这些值,则 推断出in the order specified by boto3

  1. Passing credentials as parameters in the boto.client() method
  2. Passing credentials as parameters when creating a Session object
  3. Environment variables
  4. Shared credential file (~/.aws/credentials)
  5. AWS config file (~/.aws/config)
  6. Assume Role provider
  7. Boto2 config file (/etc/boto.cfg and ~/.boto)
  8. Instance metadata service on an Amazon EC2 instance that has an IAM role configured.
frommurmurationimportkms_wrappedplaintext='the quick brown fox jumps over the lazy dog'key_alias='my kms key alias'ciphertext=kms_wrapped.encrypt(plaintext,key_alias,region='us-west-1',profile='company')decrypted=kms_wrapped.decrypt(ciphertext,region='us-west-1',profile='company')assertdecrypted==plaintext

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JAVAlang.NoSuchFieldError:类“Ljava/lang/Integer”中没有“I”字段“value”或者它的超类Android 10   java错误:SSLHandshakeException   当我缩小外圆时,有没有办法让一个圆覆盖另一个圆   java如何使用Jackson流式API编写地图列表   数组在线程“awteventque0”java中出现异常。lang.ArrayIndexOutofBounds异常:2   java删除带有大量尾随0的浮点字符串上的科学符号   java如何从get请求中获取参数?   java在Restlet中检索资源id   java OpenGL(LWJGL)TileMap仅显示一个tile   java JNA检测音频设备到达/删除   java Spring Boot JPA是否可以使用IDENTITY generator或等效程序进行批插入?   java如何使用ApachePOI根据行数将excel文件拆分为多个文件?   在Java中使用循环而不是类来获取要舍入的数字   子类中的java抛出错误、异常和运行时异常