用于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第三方库


热门话题
java变量始终存储0值。为什么?   如何使用Java/REST将Azure blob从一个存储容器移动到另一个存储容器?   java将commons DBCP从1.2升级到1.4,我应该害怕吗?   java如何使用分隔符拆分字符串?   java使用数组读取json对象   java在groovy中切片字符串   交换数组java的两个邻域元素   java移动用于确定字符串是否为回文的逻辑   java Android应用程序在一个活动中崩溃   java Sparkjava将webapp文件夹设置为静态资源/模板的文件夹   java复杂条件表达式,用户易用。   java如何仅在表存在时从表中选择值   java I无法将数据从Recyclerview传递到其他活动   java数据结构最佳设计(大数据)   java Android从DatePickerDialogFragment中删除日历视图   java将数据从Firebase获取到片段   数组。sort()在java中运行不正常