当前位置: 首页>>代码示例>>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;未经允许,请勿转载。