Decrypt document with a password.
762919
def authenticate(self, password):
        """"""
        if self.isClosed:
            raise ValueError("operation illegal for closed doc")

        val = _fitz.Document_authenticate(self, password)

        if val: # the doc is decrypted successfully and we init the outline
            self.isEncrypted = 0
            self.initData()
            self.thisown = True


        return val
609089
def Decrypt(self, data, iv):
    """"""
    key = rdf_crypto.EncryptionKey(self.cipher.key)
    iv = rdf_crypto.EncryptionKey(iv)
    return rdf_crypto.AES128CBCCipher(key, iv).Decrypt(data)
1220172
public static void decryptFile(File encryptedFile, File result, String password) throws IOException {
        byte[] b = readBytes(encryptedFile);
        String decryptedImageString = new RNCryptorNative().decrypt(new String(b), password);
        byte[] decodedBytes = Base64.decode(decryptedImageString, 0);
        writeBytes(result, decodedBytes);
    }
778307
private void decipherPassword(JournalEntryContext context) {
        String key = JournalHelper.formatDate(context.now());
        String passwordCipher = context.getPassword();
        String clearPassword =
                PasswordCipher.decipher(key, passwordCipher, passwordType);
        context.setPassword(clearPassword);
    }
874512
def decrypt(self, orig_pkt, assoclen=None):
        """"""
        hdr = copy.deepcopy(orig_pkt)
        del hdr[MACsec].payload
        pktlen = len(orig_pkt)
        if self.send_sci:
            hdrlen = NOSCI_LEN + SCI_LEN
        else:
            hdrlen = NOSCI_LEN
        if assoclen is None or not self.do_encrypt:
            if self.do_encrypt:
                assoclen = hdrlen
            else:
                assoclen = pktlen - self.icvlen
        iv = self.make_iv(hdr)
        assoc, ct, icv = MACsecSA.split_pkt(orig_pkt, assoclen, self.icvlen)
        decryptor = Cipher(
            algorithms.AES(self.key),
            modes.GCM(iv, icv),
            backend=default_backend()
        ).decryptor()
        decryptor.authenticate_additional_data(assoc)
        pt = assoc[hdrlen:assoclen]
        pt += decryptor.update(ct)
        pt += decryptor.finalize()
        hdr[MACsec].type = struct.unpack('!H', pt[0:2])[0]
        hdr[MACsec].payload = Raw(pt[2:])
        return hdr
923408
def decrypt(self, enctext, key_file=None, id_attr=''):
        
        if not id_attr:
            id_attr = self.id_attr

        if not isinstance(key_file, list):
            key_file = [key_file]

        key_files = [
            key for key in itertools.chain(key_file, self.enc_key_files) if key
        ]
        for key_file in key_files:
            try:
                dectext = self.crypto.decrypt(enctext, key_file, id_attr)
            except XmlsecError as e:
                continue
            else:
                if dectext:
                    return dectext

        errmsg = "No key was able to decrypt the ciphertext. Keys tried: {keys}"
        errmsg = errmsg.format(keys=key_files)
        raise DecryptError(errmsg)
401925
def DecryptPassword(cipher, key):
		
		import base64
		import hmac
		import sha
		from array import array

		H = UcsUtils.GetShaHash

		cipher = cipher + "\n"
		cipher = base64.decodestring(cipher)
		n = len(cipher) - 16 - 8

		uhash = cipher[:16]
		passwordStream = cipher[16:-8] + "0000"[n & 3:]
		auth = cipher[-8:]

		k_enc, k_auth = H('enc' + key + uhash), H('auth' + key + uhash)
		vauth = hmac.new(cipher[-8:], k_auth, sha).digest()[:8]

		passwordStream = array('L', passwordStream)
		xkey = UcsUtils.Expandkey(k_enc, n + 4)

		for i in xrange(len(passwordStream)):
			passwordStream[i] = passwordStream[i] ^ xkey[i]

		decryptedPassword = passwordStream.tostring()[:n]
		return decryptedPassword
1034541
def decrypt(payload, private_key):
        """"""
        cipher = PKCS1_v1_5.new(private_key)
        aes_key_str = cipher.decrypt(b64decode(payload.get("aes_key")), sentinel=None)
        aes_key = json.loads(aes_key_str.decode("utf-8"))
        key = b64decode(aes_key.get("key"))
        iv = b64decode(aes_key.get("iv"))
        encrypted_magic_envelope = b64decode(payload.get("encrypted_magic_envelope"))
        encrypter = AES.new(key, AES.MODE_CBC, iv)
        content = encrypter.decrypt(encrypted_magic_envelope)
        return etree.fromstring(pkcs7_unpad(content))
800765
def getCipherText(self, iv, key, plaintext):
        
        cipher = AESCipher(key, iv)
        return cipher.encrypt(bytes(plaintext))
13582
def decrypt(source_text, passphrase, debug_stmt=None):
    
    if debug_stmt is None:
        debug_stmt = "decrypt"
    full_encrypted = b64decode(source_text)
    salt = full_encrypted[8:IV_BLOCK_SIZE]
    encrypted_text = full_encrypted[IV_BLOCK_SIZE:]
    key, iv_ = _openssl_key_iv(passphrase, salt)
    cipher = Cipher(
        algorithms.AES(key), modes.CBC(iv_), default_backend()
    ).decryptor()
    plain_text = cipher.update(encrypted_text)
    plain_text += cipher.finalize()
    # PKCS#7 padding
    if six.PY2:
        padding = ord(plain_text[-1])
    else:
        padding = plain_text[-1]
    plain_text = plain_text[:-padding]
    if hasattr(plain_text, 'decode'):
        plain_text = plain_text.decode('utf-8')
    _log_debug(salt, key, iv_, source_text, plain_text,
        passphrase=passphrase, debug_stmt=debug_stmt)
    return plain_text
1349002
def decrypt(self, value):
        """"""
        try:
            value, timestamp, signature = value.split("|")
        except ValueError:
            return None
        if check_signature(signature, self.secret, value + timestamp, encoding=self.encoding):
            return base64.b64decode(value).decode(self.encoding)
696052
def decrypt_key(key, password):
    
    private = serialization.load_pem_private_key(key, password=password, backend=default_backend())
    return private.private_bytes(Encoding.PEM, PrivateFormat.PKCS8, NoEncryption())
779668
def symmetric_decrypt_HMAC(cyphertext, key, hmac_secret):
    """"""
    iv = symmetric_decrypt_iv(cyphertext, key)
    message = symmetric_decrypt_with_iv(cyphertext, key, iv)

    hmac = hmac_sha1(hmac_secret, iv[-3:] + message)

    if iv[:13] != hmac[:13]:
        raise RuntimeError("Unable to decrypt message. HMAC does not match.")

    return message
996395
def read(self, encoding="utf8"):
        
        with open(self._filename, "rb") as f:
            if self.key:
                return get_module("mo_math.crypto").decrypt(f.read(), self.key)
            else:
                content = f.read().decode(encoding)
                return content
531471
def _maybe_encrypt_password(role,
                            password,
                            encrypted=_DEFAULT_PASSWORDS_ENCRYPTION):
    '''
    
    '''
    if password is not None:
        password = six.text_type(password)
    if encrypted and password and not password.startswith('md5'):
        password = "md5{0}".format(
            hashlib.md5(salt.utils.stringutils.to_bytes('{0}{1}'.format(password, role))).hexdigest())
    return password
212074
def decrypt_file(path, password=None):
    '''
    
    '''
    global PASSWORD_FILE
    if not password:
        password = PASSWORD_FILE
    if path and not os.path.isfile(path):
        raise SystemExit(_error_codes.get(106))
    query = 'openssl aes-128-cbc -d -salt -in {0} -out {1} -k {2}'
    with hide('output'):
        local(query.format(path, path + '.tar.gz', PASSWORD_FILE))
204092
def encrypt_password(self):
        
        if self.password and not self.password.startswith('$pbkdf2'):
            self.set_password(self.password)