當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。