當前位置: 首頁>>代碼示例>>Python>>正文


Python Cipher.encrypt方法代碼示例

本文整理匯總了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")
開發者ID:Insaida,項目名稱:NSFcryptTool,代碼行數:11,代碼來源:aristocrat.py

示例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
開發者ID:ZhuZhengyi,項目名稱:ipmsg-1,代碼行數:34,代碼來源:__init__.py

示例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)))
開發者ID:Insaida,項目名稱:NSFcryptTool,代碼行數:5,代碼來源:patristocrat.py

示例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)))
開發者ID:Insaida,項目名稱:NSFcryptTool,代碼行數:6,代碼來源:aristocrat.py

示例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())
開發者ID:Insaida,項目名稱:NSFcryptTool,代碼行數:5,代碼來源:aristocrat.py


注:本文中的cipher.Cipher.encrypt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。