本文整理匯總了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())