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


Python pyaes.AESModeOfOperationCTR方法代码示例

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


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

示例1: __init__

# 需要导入模块: import pyaes [as 别名]
# 或者: from pyaes import AESModeOfOperationCTR [as 别名]
def __init__(self, key, iv):
        """
        Initializes the AES CTR mode with the given key/iv pair.

        :param key: the key to be used as bytes.
        :param iv: the bytes initialization vector. Must have a length of 16.
        """
        # TODO Use libssl if available
        assert isinstance(key, bytes)
        self._aes = pyaes.AESModeOfOperationCTR(key)

        assert isinstance(iv, bytes)
        assert len(iv) == 16
        self._aes._counter._counter = list(iv) 
开发者ID:LonamiWebs,项目名称:Telethon,代码行数:16,代码来源:aesctr.py

示例2: decrypt_file_pyaes

# 需要导入模块: import pyaes [as 别名]
# 或者: from pyaes import AESModeOfOperationCTR [as 别名]
def decrypt_file_pyaes(file_name, key):
    aes = pyaes.AESModeOfOperationCTR(key)

    with open(file_name, 'rb') as fo:
        plaintext = fo.read()
    dec = aes.decrypt(plaintext)
    with open(file_name[:-6], 'wb') as fo:
        fo.write(dec) 
开发者ID:leonv024,项目名称:RAASNet,代码行数:10,代码来源:decrypt.py

示例3: decrypt

# 需要导入模块: import pyaes [as 别名]
# 或者: from pyaes import AESModeOfOperationCTR [as 别名]
def decrypt(ciphertxt):
    """
    Decrypt credentails
    """
    hashed = pyscrypt.hash(PHRASE, SALT, 1024, 1, 1, 16)
    key = hashed.encode('hex')
    aes = pyaes.AESModeOfOperationCTR(key)
    cleartxt = aes.decrypt(ciphertxt.decode('hex'))
    return cleartxt 
开发者ID:ekiojp,项目名称:circo,代码行数:11,代码来源:carpa.py

示例4: encrypt

# 需要导入模块: import pyaes [as 别名]
# 或者: from pyaes import AESModeOfOperationCTR [as 别名]
def encrypt(cleartxt):
    hashed = pyscrypt.hash(PHRASE, SALT, 1024, 1, 1, 16)
    key = hashed.encode('hex')
    aes = pyaes.AESModeOfOperationCTR(key)
    ciphertxt = aes.encrypt(cleartxt)
    return ciphertxt.encode('hex') 
开发者ID:ekiojp,项目名称:circo,代码行数:8,代码来源:circo.py

示例5: decrypt

# 需要导入模块: import pyaes [as 别名]
# 或者: from pyaes import AESModeOfOperationCTR [as 别名]
def decrypt(ciphertxt):
    hashed = pyscrypt.hash(PHRASE, SALT, 1024, 1, 1, 16)
    key = hashed.encode('hex')
    aes = pyaes.AESModeOfOperationCTR(key)
    cleartxt = aes.decrypt(ciphertxt.decode('hex'))
    return cleartxt 
开发者ID:ekiojp,项目名称:circo,代码行数:8,代码来源:jaula_chip.py

示例6: decrypti

# 需要导入模块: import pyaes [as 别名]
# 或者: from pyaes import AESModeOfOperationCTR [as 别名]
def decrypti(ciphertxt):
    hashed = pyscrypt.hash(PHRASE, SALT, 1024, 1, 1, 16)
    key = hashed.encode('hex')
    aes = pyaes.AESModeOfOperationCTR(key)
    cleartxt = aes.decrypt(ciphertxt.decode('hex'))
    return cleartxt 
开发者ID:ekiojp,项目名称:circo,代码行数:8,代码来源:jaula_rpz.py

示例7: use_slow_bundled_cryptography_module

# 需要导入模块: import pyaes [as 别名]
# 或者: from pyaes import AESModeOfOperationCTR [as 别名]
def use_slow_bundled_cryptography_module():
    import pyaes

    msg = "To make the program a *lot* faster, please install cryptography module: "
    msg += "pip install cryptography\n"
    print(msg, flush=True, file=sys.stderr)

    class BundledEncryptorAdapter:
        __slots__ = ('mode', )

        def __init__(self, mode):
            self.mode = mode

        def encrypt(self, data):
            encrypter = pyaes.Encrypter(self.mode, pyaes.PADDING_NONE)
            return encrypter.feed(data) + encrypter.feed()

        def decrypt(self, data):
            decrypter = pyaes.Decrypter(self.mode, pyaes.PADDING_NONE)
            return decrypter.feed(data) + decrypter.feed()

    def create_aes_ctr(key, iv):
        ctr = pyaes.Counter(iv)
        return pyaes.AESModeOfOperationCTR(key, ctr)

    def create_aes_cbc(key, iv):
        mode = pyaes.AESModeOfOperationCBC(key, iv)
        return BundledEncryptorAdapter(mode)
    return create_aes_ctr, create_aes_cbc 
开发者ID:alexbers,项目名称:mtprotoproxy,代码行数:31,代码来源:mtprotoproxy.py

示例8: aes_encrypt

# 需要导入模块: import pyaes [as 别名]
# 或者: from pyaes import AESModeOfOperationCTR [as 别名]
def aes_encrypt(self, key=None, chunksize=64 * 1024):
        self.out_filename = self.out_filename or self.in_filename + '.enc'
        if key is None:
            key = base64.b64encode(os.urandom(32))[:32]
        aes = pyaes.AESModeOfOperationCTR(key)
        with open(self.in_filename, 'rb') as infile:
            with open(self.out_filename, 'wb') as outfile:
                pyaes.encrypt_stream(aes, infile, outfile)
        return key 
开发者ID:ywangd,项目名称:stash,代码行数:11,代码来源:crypt.py

示例9: aes_decrypt

# 需要导入模块: import pyaes [as 别名]
# 或者: from pyaes import AESModeOfOperationCTR [as 别名]
def aes_decrypt(self, key, chunksize=64 * 1024):
        self.out_filename = self.out_filename or os.path.splitext(self.in_filename)[0]
        aes = pyaes.AESModeOfOperationCTR(key)

        with open(self.in_filename, 'rb') as infile:
            with open(self.out_filename, 'wb') as outfile:
                pyaes.decrypt_stream(aes, infile, outfile) 
开发者ID:ywangd,项目名称:stash,代码行数:9,代码来源:crypt.py

示例10: aes_setup

# 需要导入模块: import pyaes [as 别名]
# 或者: from pyaes import AESModeOfOperationCTR [as 别名]
def aes_setup(self, session_key):
        # Load keys and define encrypt/decrypt functions
        # - for CTR mode, we have different counters in each direction, so need two instances
        # - count must start at zero, and increment in LSB for each block.
        import pyaes

        self.encrypt_request = pyaes.AESModeOfOperationCTR(session_key, pyaes.Counter(0)).decrypt
        self.decrypt_response = pyaes.AESModeOfOperationCTR(session_key, pyaes.Counter(0)).encrypt 
开发者ID:bitcoin-core,项目名称:HWI,代码行数:10,代码来源:client.py

示例11: aes_mode_of_operation

# 需要导入模块: import pyaes [as 别名]
# 或者: from pyaes import AESModeOfOperationCTR [as 别名]
def aes_mode_of_operation(key):
    return pyaes.AESModeOfOperationCTR(from_safe_string(key)) 
开发者ID:okpy,项目名称:ok-client,代码行数:4,代码来源:encryption.py


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