本文整理汇总了Python中cipher.Cipher.encrypt方法的典型用法代码示例。如果您正苦于以下问题:Python Cipher.encrypt方法的具体用法?Python Cipher.encrypt怎么用?Python Cipher.encrypt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cipher.Cipher
的用法示例。
在下文中一共展示了Cipher.encrypt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display
# 需要导入模块: from cipher import Cipher [as 别名]
# 或者: from cipher.Cipher import encrypt [as 别名]
def display(self):
data = ""
ct = shared.breaklines(Cipher.encrypt(self.cipher), self.maxlinelen).split("n")
pt = shared.breaklines(self.cipher.decrypt(), self.maxlinelen).split("n")
for index in range(len(ct)):
data += ct[index] + "n"
data += pt[index] + "nn"
print data.strip("n")
示例2: encrypt
# 需要导入模块: from cipher import Cipher [as 别名]
# 或者: from cipher.Cipher import encrypt [as 别名]
def encrypt(self, msg, addr):
logger.debug('before encryption')
if not self.knows(addr):
logger.debug('dont know who')
return False, None
logger.debug('checking methods')
methods = self.get_methods(shex(self.contact_capa[addr]))
if None in methods:
logger.debug('dont have methods')
return False, None
rsa_tag, cipher_tag = methods
logger.debug('methods checked: rsa_tag=%s, cipher_tag=%s' % (rsa_tag, cipher_tag))
try:
rsa_key = self.contact_keys[addr][RSALEN[rsa_tag]]
except KeyError:
logger.debug('does not have public key for %s, %s' % (repr(addr), RSALEN[rsa_tag]))
return False, None
logger.debug('got rsa key %s' % (RSALEN[rsa_tag]))
cipher = Cipher(*CIPHERS[cipher_tag])
logger.debug('ready to encypt cipher')
enc_msg = cipher.encrypt(msg)
enc_ses_key = rsa_key.encrypt(cipher.session_key)
capa = shex(rsa_tag | cipher_tag)
enc_raw = capa + ':' + binascii.b2a_hex(enc_ses_key) + ':' + binascii.b2a_hex(enc_msg)
logger.debug('encryption ok')
return True, enc_raw
示例3: frequency_list
# 需要导入模块: from cipher import Cipher [as 别名]
# 或者: from cipher.Cipher import encrypt [as 别名]
def frequency_list(self, length = 1, text = ""):
text = Cipher.encrypt(self.cipher, text)
self.print_counts(shared.calc_graphs(text, int(length)))
示例4: frequency_list
# 需要导入模块: from cipher import Cipher [as 别名]
# 或者: from cipher.Cipher import encrypt [as 别名]
def frequency_list(self, length = 1, text = ""):
"""Displays counts for frequencies of characters"""
text = Cipher.encrypt(self.cipher, text)
self.print_counts(shared.calc_graphs(text.split(" "), int(length)))
示例5: encrypt
# 需要导入模块: from cipher import Cipher [as 别名]
# 或者: from cipher.Cipher import encrypt [as 别名]
def encrypt(self, text = ""):
text = Cipher.encrypt(self, text)
return self.process(self.ptkey, self.ctkey, text.lower())