Given a blob of ciphertext as a bytestring, try to decrypt
    the cipher and return the decrypted string. If the cipher cannot be
    decrypted, log the error, and return the ciphertext back out.
512772
def _decrypt_ciphertext(cipher, translate_newlines=False):
    '''
    
    '''
    if translate_newlines:
        cipher = cipher.replace(r'\n', '\n')
    if hasattr(cipher, 'encode'):
        cipher = cipher.encode(__salt_system_encoding__)

    # Decryption
    data_key = _base64_plaintext_data_key()
    plain_text = fernet.Fernet(data_key).decrypt(cipher)
    if hasattr(plain_text, 'decode'):
        plain_text = plain_text.decode(__salt_system_encoding__)
    return six.text_type(plain_text)
625194
def decrypt(self, message):
        

        # Unserialize the encrypted message
        message = json.loads(message)

        # Set up a list for the unencrypted lines of the message
        unencrypted_msg = []

        for line in message:

            # Convert from ascii back to bytestring
            enc_line = binascii.a2b_base64(line)

            # Decrypt the line using our private key
            unencrypted_line = rsa.decrypt(enc_line, self.private_key)

            unencrypted_msg.append(unencrypted_line)

        # Convert the message from a list back into a string
        unencrypted_msg = "".join(unencrypted_msg)

        return unencrypted_msg
1364840
def decrypt(data, _key):
    
    # Key and iv have not been generated or provided, bail out
    if _key is None:
        Log.error("Expecting a key")

    _input = get_module("mo_json").json2value(data.decode('utf8'), leaves=False, flexible=False)

    # Initialize encryption using key and iv
    key_expander_256 = key_expander.KeyExpander(256)
    expanded_key = key_expander_256.expand(_key)
    aes_cipher_256 = aes_cipher.AESCipher(expanded_key)
    aes_cbc_256 = cbc_mode.CBCMode(aes_cipher_256, 16)
    aes_cbc_256.set_iv(base642bytearray(_input.salt))

    raw = base642bytearray(_input.data)
    out_data = bytearray()
    for _, e in _groupby16(raw):
        out_data.extend(aes_cbc_256.decrypt_block(e))

    if _input.encoding:
        return binary_type(out_data[:_input.length:]).decode(_input.encoding)
    else:
        return binary_type(out_data[:_input.length:])
1104354
def decrypt(self, password_encrypted):
        
        if not password_encrypted or not self._crypter:
            return password_encrypted or b''
        return self._crypter.decrypt(password_encrypted)
689853
def crypt(self, data, crypt_type):
        """"""

        # Error check the data
        if not data:
            return ''
        if len(data) % self.block_size != 0:
            if crypt_type == des.DECRYPT: # Decryption must work on 8 byte blocks
                raise ValueError("Invalid data length, data must be a multiple of " + str(self.block_size) + " bytes\n" + data + ".")
            if not self.getPadding():
                raise ValueError("Invalid data length, data must be a multiple of " + str(self.block_size) + " bytes\n. Try setting the optional padding character")
            else:
                data += (self.block_size - (len(data) % self.block_size)) * self.getPadding()
            # print "Len of data: %f" % (len(data) / self.block_size)

        if self.getMode() == CBC:
            if self.getIV():
                iv = self.__String_to_BitList(self.getIV())
            else:
                raise ValueError("For CBC mode, you must supply the Initial Value (IV) for ciphering")

        # Split the data into blocks, crypting each one seperately
        i = 0
        result = []
        while i < len(data):
            block = self.__String_to_BitList(data[i:i+8])

            # Xor with IV if using CBC mode
            if self.getMode() == CBC:
                if crypt_type == des.ENCRYPT:
                    block = list(map(lambda x, y: x ^ y, block, iv))

                processed_block = self.__des_crypt(block, crypt_type)

                if crypt_type == des.DECRYPT:
                    processed_block = list(map(lambda x, y: x ^ y, processed_block, iv))
                    iv = block
                else:
                    iv = processed_block
            else:
                processed_block = self.__des_crypt(block, crypt_type)


            # Add the resulting crypted block to our list
            result.append(self.__BitList_to_String(processed_block))
            i += 8

        # Return the full crypted string
        if _pythonMajorVersion < 3:
            return ''.join(result)
        else:
            return bytes.fromhex('').join(result)
629416
def decrypt(self, data, decode=False):
		

		#result = self.cipher().decrypt(data)
		result = self.cipher().decrypt_block(data)

		padding = self.mode().padding()
		if padding is not None:
			result = padding.reverse_pad(result, WAESMode.__data_padding_length__)

		return result.decode() if decode else result
1298020
final byte[] crypto(final byte[] input, final int offset, final int len, final boolean decrypt)
			throws InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException,
			BadPaddingException {
		aesCipher.init(decrypt ? Cipher.DECRYPT_MODE : Cipher.ENCRYPT_MODE, aesKey, aesIV);
		return aesCipher.doFinal(input, offset, len);
	}
95255
def decrypt(self, data):
        
        next_payload, is_critical, payload_len = const.PAYLOAD_HEADER.unpack(data[:const.PAYLOAD_HEADER.size])
        next_payload = payloads.Type(next_payload)
        logger.debug("next payload: {!r}".format(next_payload))
        try:
            iv_len = 16
            iv = bytes(data[const.PAYLOAD_HEADER.size:const.PAYLOAD_HEADER.size + iv_len])
            ciphertext = bytes(data[const.PAYLOAD_HEADER.size + iv_len:payload_len])  # HMAC size
        except IndexError:
            raise IkeError('Unable to decrypt: Malformed packet')
        logger.debug('IV: {}'.format(dump(iv)))
        logger.debug('CIPHERTEXT: {}'.format(dump(ciphertext)))
        # Decrypt
        cipher = Camellia(self.SK_er, iv=iv)
        decrypted = cipher.decrypt(ciphertext)
        logger.debug("Decrypted packet from responder: {}".format(dump(decrypted)))
        return next_payload, decrypted
203761
def decrypt_binary(self, binary, *args, **kwargs):
        
        return self.decrypt(binary, *args, **kwargs)
1174112
protected static final byte[] decrypt(byte[] msg, byte[] key, String cipher) throws Exception {
        SecretKey sKey = constructSecretKey(key, cipher);
        Cipher ci = createCipher(Cipher.DECRYPT_MODE, key, cipher, sKey);
        return ci.doFinal(msg);
    }
1267054
def decrypt(self, ciphertext):
        ''

        if len(ciphertext) != 16:
            raise ValueError('wrong block length')

        rounds = len(self._Kd) - 1
        (s1, s2, s3) = [3, 2, 1]
        a = [0, 0, 0, 0]

        # Convert ciphertext to (ints ^ key)
        t = [(_compact_word(ciphertext[4 * i:4 * i + 4]) ^ self._Kd[0][i]) for i in xrange(0, 4)]

        # Apply round transforms
        for r in xrange(1, rounds):
            for i in xrange(0, 4):
                a[i] = (self.T5[(t[ i          ] >> 24) & 0xFF] ^
                        self.T6[(t[(i + s1) % 4] >> 16) & 0xFF] ^
                        self.T7[(t[(i + s2) % 4] >>  8) & 0xFF] ^
                        self.T8[ t[(i + s3) % 4]        & 0xFF] ^
                        self._Kd[r][i])
            t = copy.copy(a)

        # The last round is special
        result = [ ]
        for i in xrange(0, 4):
            tt = self._Kd[rounds][i]
            result.append((self.Si[(t[ i           ] >> 24) & 0xFF] ^ (tt >> 24)) & 0xFF)
            result.append((self.Si[(t[(i + s1) % 4] >> 16) & 0xFF] ^ (tt >> 16)) & 0xFF)
            result.append((self.Si[(t[(i + s2) % 4] >>  8) & 0xFF] ^ (tt >>  8)) & 0xFF)
            result.append((self.Si[ t[(i + s3) % 4]        & 0xFF] ^  tt       ) & 0xFF)

        return result
1090306
public byte[] decrypt(byte[] text, PrivateKey key) throws MangooEncryptionException {
        Objects.requireNonNull(text, Required.ENCRYPTED_TEXT.toString());
        Objects.requireNonNull(text, Required.PRIVATE_KEY.toString());

        byte[] decrypt = null;
        try {
            Cipher cipher = Cipher.getInstance(ENCRYPTION);
            cipher.init(Cipher.DECRYPT_MODE, key);
            decrypt = cipher.doFinal(text);
        } catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException | BadPaddingException e) {
            throw new MangooEncryptionException("Failed to decrypt encrypted text with private key", e);
        }
        
        return decrypt;
    }
116373
public static String decrypt(String encrypted) {
        try {
            return decrypt(encrypted, null);
        } catch (GeneralSecurityException e) {
            e.printStackTrace();
            return null;
        }
    }
563479
public String decryptStr(byte[] bytes, Charset charset) {
		return StrUtil.str(decrypt(bytes), charset);
	}
1073475
def decrypt(message):
    '''
    '''
    try:
        ret = kms.decrypt(
            CiphertextBlob=base64.decodestring(message))
        decrypted_data = ret.get('Plaintext')
    except Exception as e:
        # returns http 500 back to user and log error details in Cloudwatch Logs
        raise Exception("Unable to decrypt data: ", e)

    return decrypted_data
538255
def decrypt(self, encrypted):
        
        decoded = b64decode(encrypted)
        init_vec = decoded[:AES.block_size]
        cipher = AES.new(self._key, AES.MODE_CBC, init_vec)

        return AESCipher.unpad(cipher.decrypt(decoded[AES.block_size:]))
1029549
def decode_bytes(byt, enc='utf-8'):
    
    try:
        strg = byt.decode(enc)
    except UnicodeDecodeError as err:
        strg = "Unable to decode message:\n{}\n{}".format(str(byt), err)
    except (AttributeError, UnicodeEncodeError):
        # If byt is already a string, just return it
        return byt
    return strg