当前位置: 首页>>代码示例>>Python>>正文


Python VaultLib.cipher_name方法代码示例

本文整理汇总了Python中ansible.parsing.vault.VaultLib.cipher_name方法的典型用法代码示例。如果您正苦于以下问题:Python VaultLib.cipher_name方法的具体用法?Python VaultLib.cipher_name怎么用?Python VaultLib.cipher_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ansible.parsing.vault.VaultLib的用法示例。


在下文中一共展示了VaultLib.cipher_name方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_encrypt_decrypt_aes256

# 需要导入模块: from ansible.parsing.vault import VaultLib [as 别名]
# 或者: from ansible.parsing.vault.VaultLib import cipher_name [as 别名]
 def test_encrypt_decrypt_aes256(self):
     if not HAS_AES or not HAS_COUNTER or not HAS_PBKDF2:
         raise SkipTest
     v = VaultLib('ansible')
     v.cipher_name = 'AES256'
     enc_data = v.encrypt("foobar")
     dec_data = v.decrypt(enc_data)
     assert enc_data != "foobar", "encryption failed"
     assert dec_data == "foobar", "decryption failed"
开发者ID:JaredPennella,项目名称:DevOps_Script,代码行数:11,代码来源:test_vault.py

示例2: test_encrypt_decrypt_aes

# 需要导入模块: from ansible.parsing.vault import VaultLib [as 别名]
# 或者: from ansible.parsing.vault.VaultLib import cipher_name [as 别名]
 def test_encrypt_decrypt_aes(self):
     if not HAS_AES or not HAS_COUNTER or not HAS_PBKDF2:
         raise SkipTest
     v = VaultLib('ansible')
     v.cipher_name = u'AES'
     # AES encryption code has been removed, so this is old output for
     # AES-encrypted 'foobar' with password 'ansible'.
     enc_data = '$ANSIBLE_VAULT;1.1;AES\n53616c7465645f5fc107ce1ef4d7b455e038a13b053225776458052f8f8f332d554809d3f150bfa3\nfe3db930508b65e0ff5947e4386b79af8ab094017629590ef6ba486814cf70f8e4ab0ed0c7d2587e\n786a5a15efeb787e1958cbdd480d076c\n'
     dec_data = v.decrypt(enc_data)
     assert dec_data == "foobar", "decryption failed"
开发者ID:JaredPennella,项目名称:DevOps_Script,代码行数:12,代码来源:test_vault.py

示例3: test_encrypt_encrypted

# 需要导入模块: from ansible.parsing.vault import VaultLib [as 别名]
# 或者: from ansible.parsing.vault.VaultLib import cipher_name [as 别名]
 def test_encrypt_encrypted(self):
     if not HAS_AES or not HAS_COUNTER or not HAS_PBKDF2:
         raise SkipTest
     v = VaultLib('ansible')
     v.cipher_name = 'AES'
     data = "$ANSIBLE_VAULT;9.9;TEST\n%s" % hexlify(six.b("ansible"))
     error_hit = False
     try:
         enc_data = v.encrypt(data)
     except errors.AnsibleError as e:
         error_hit = True
     assert error_hit, "No error was thrown when trying to encrypt data with a header"
开发者ID:JaredPennella,项目名称:DevOps_Script,代码行数:14,代码来源:test_vault.py

示例4: test_format_output

# 需要导入模块: from ansible.parsing.vault import VaultLib [as 别名]
# 或者: from ansible.parsing.vault.VaultLib import cipher_name [as 别名]
 def test_format_output(self):
     v = VaultLib('ansible')
     v.cipher_name = "TEST"
     sensitive_data = "ansible"
     data = v._format_output(sensitive_data)
     lines = data.split(b'\n')
     assert len(lines) > 1, "failed to properly add header"
     header = to_unicode(lines[0])
     assert header.endswith(';TEST'), "header does end with cipher name"
     header_parts = header.split(';')
     assert len(header_parts) == 3, "header has the wrong number of parts"
     assert header_parts[0] == '$ANSIBLE_VAULT', "header does not start with $ANSIBLE_VAULT"
     assert header_parts[1] == v.b_version, "header version is incorrect"
     assert header_parts[2] == 'TEST', "header does end with cipher name"
开发者ID:JaredPennella,项目名称:DevOps_Script,代码行数:16,代码来源:test_vault.py

示例5: test_add_header

# 需要导入模块: from ansible.parsing.vault import VaultLib [as 别名]
# 或者: from ansible.parsing.vault.VaultLib import cipher_name [as 别名]
 def test_add_header(self):
     v = VaultLib("ansible")
     v.cipher_name = "TEST"
     sensitive_data = "ansible"
     data = v._add_header(sensitive_data)
     lines = data.split("\n")
     assert len(lines) > 1, "failed to properly add header"
     header = lines[0]
     assert header.endswith(";TEST"), "header does end with cipher name"
     header_parts = header.split(";")
     assert len(header_parts) == 3, "header has the wrong number of parts"
     assert header_parts[0] == "$ANSIBLE_VAULT", "header does not start with $ANSIBLE_VAULT"
     assert header_parts[1] == v.version, "header version is incorrect"
     assert header_parts[2] == "TEST", "header does end with cipher name"
开发者ID:jinnko,项目名称:ansible,代码行数:16,代码来源:test_vault.py


注:本文中的ansible.parsing.vault.VaultLib.cipher_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。