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


Python aes.decryptData方法代碼示例

本文整理匯總了Python中aes.decryptData方法的典型用法代碼示例。如果您正苦於以下問題:Python aes.decryptData方法的具體用法?Python aes.decryptData怎麽用?Python aes.decryptData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在aes的用法示例。


在下文中一共展示了aes.decryptData方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: aes_decrypt

# 需要導入模塊: import aes [as 別名]
# 或者: from aes import decryptData [as 別名]
def aes_decrypt(ciphertext, key, iv):
    decoded = ciphertext.decode('base64')
    password = aes.decryptData(key, iv.encode('utf-8') + decoded)
    return unicode(password, 'utf-8') 
開發者ID:methos2016,項目名稱:recon-ng,代碼行數:6,代碼來源:crypto.py

示例2: decrypt_privkey

# 需要導入模塊: import aes [as 別名]
# 或者: from aes import decryptData [as 別名]
def decrypt_privkey(encr_privkey, pw):

    bin_pwhash = bin_hash_password(pw)
    bin_encr_privkey = encr_privkey.decode('hex')
    privkey = aes.decryptData(bin_pwhash, bin_encr_privkey)

    return privkey 
開發者ID:christianlundkvist,項目名稱:bitcoinista,代碼行數:9,代碼來源:wallet.py

示例3: computeEncryptionKey

# 需要導入模塊: import aes [as 別名]
# 或者: from aes import decryptData [as 別名]
def computeEncryptionKey(password, dictOwnerPass, dictUserPass, dictOE, dictUE, fileID, pElement, dictKeyLength = 128, revision = 3, encryptMetadata = False, passwordType = None):
    '''
        Compute an encryption key to encrypt/decrypt the PDF file
        
        @param password: The password entered by the user
        @param dictOwnerPass: The owner password from the standard security handler dictionary
        @param dictUserPass: The user password from the standard security handler dictionary
        @param dictOE: The owner encrypted string from the standard security handler dictionary
        @param dictUE:The user encrypted string from the standard security handler dictionary
        @param fileID: The /ID element in the trailer dictionary of the PDF file
        @param pElement: The /P element of the Encryption dictionary
        @param dictKeyLength: The length of the key
        @param revision: The algorithm revision
        @param encryptMetadata: A boolean extracted from the standard security handler dictionary to specify if it's necessary to encrypt the document metadata or not
        @param passwordType: It specifies the given password type. It can be 'USER', 'OWNER' or None.
        @return: A tuple (status,statusContent), where statusContent is the encryption key in case status = 0 or an error message in case status = -1
    '''
    if revision != 5:
        keyLength = dictKeyLength/8
        lenPass = len(password)
        if lenPass > 32:
            password = password[:32]
        elif lenPass < 32:
            password += paddingString[:32-lenPass]
        md5input = password + dictOwnerPass + struct.pack('<I',abs(int(pElement))) + fileID
        if revision > 3 and not encryptMetadata:
            md5input += '\xFF'*4
        key = hashlib.md5(md5input).digest()
        if revision > 2:
            counter = 0
            while counter < 50:
                key = hashlib.md5(key[:keyLength]).digest()
                counter += 1
            key = key[:keyLength]
        elif revision == 2:
            key = key[:5]
        return (0, key)
    else:
        if passwordType == 'USER':
            password = password.encode('utf-8')[:127]
            kSalt = dictUserPass[40:48]
            intermediateKey = hashlib.sha256(password + kSalt).digest()
            ret = aes.decryptData('\0'*16+dictUE, intermediateKey)
        elif passwordType == 'OWNER':
            password = password.encode('utf-8')[:127]
            kSalt = dictOwnerPass[40:48]
            intermediateKey = hashlib.sha256(password + kSalt + dictUserPass).digest()
            ret = aes.decryptData('\0'*16+dictOE, intermediateKey)
        return ret 
開發者ID:opensourcesec,項目名稱:CIRTKit,代碼行數:51,代碼來源:PDFCrypto.py


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