Attempts to decrypt a file
325765
def decrypt(source, dest=None, passphrase=None):
    """"""
    if not os.path.exists(source):
        raise CryptoritoError("Encrypted file %s not found" % source)

    cmd = [gnupg_bin(), gnupg_verbose(), "--decrypt", gnupg_home(),
           passphrase_file(passphrase)]

    if dest:
        cmd.append(["--output", dest])

    cmd.append([source])
    stderr_output(flatten(cmd))
    return True
847476
def _decrypt(self, data, key):
        """"""
        seed1 = key
        seed2 = 0xEEEEEEEE
        result = BytesIO()

        for i in range(len(data) // 4):
            seed2 += self.encryption_table[0x400 + (seed1 & 0xFF)]
            seed2 &= 0xFFFFFFFF
            value = struct.unpack("<I", data[i*4:i*4+4])[0]
            value = (value ^ (seed1 + seed2)) & 0xFFFFFFFF

            seed1 = ((~seed1 << 0x15) + 0x11111111) | (seed1 >> 0x0B)
            seed1 &= 0xFFFFFFFF
            seed2 = value + seed2 + (seed2 << 5) + 3 & 0xFFFFFFFF

            result.write(struct.pack("<I", value))

        return result.getvalue()
228309
def _decrypt_object(obj):
    '''
    
    '''
    if isinstance(obj, six.string_types):
        return _fetch_secret(obj)
    elif isinstance(obj, dict):
        for pass_key, pass_path in six.iteritems(obj):
            obj[pass_key] = _decrypt_object(pass_path)
    elif isinstance(obj, list):
        for pass_key, pass_path in enumerate(obj):
            obj[pass_key] = _decrypt_object(pass_path)
    return obj
1274208
def decrypt(self, ciphertext):
        """"""
        if not isinstance(ciphertext, int):
            raise ValueError('Ciphertext must be an integer value')
        if not self.out_range.contains(ciphertext):
            raise OutOfRangeError('Ciphertext is not within the output range')
        return self.decrypt_recursive(ciphertext, self.in_range, self.out_range)
387712
def decrypt(content_entry, cipher)
      # Zip::Entry.extract writes a 0-length file when trying
      # to extract an encrypted stream, so we read the
      # raw bytes based on the offset and lengths
      decrypted = ''
      File.open(@filename, 'rb') do |zipfile|
        zipfile.seek(
          content_entry.local_header_offset +
            content_entry.calculate_local_header_size
        )
        total_to_read = content_entry.compressed_size

        block_size = 4096
        block_size = total_to_read if block_size > total_to_read

        while (buffer = zipfile.read(block_size))
          decrypted     += cipher.update(buffer)
          total_to_read -= buffer.length

          break if total_to_read == 0

          block_size = total_to_read if block_size > total_to_read
        end
      end

      decrypted + cipher.final
    end
699839
def decrypt(self, data, nounce=None):
        """"""
        if nounce is None:
            nounce = self._in_counter.to_bytes(length=8, byteorder='little')
            self._in_counter += 1

        decrypted = self._enc_in.open(
            b'\x00\x00\x00\x00' + nounce, data, bytes())

        if not decrypted:
            raise Exception('data decrypt failed')  # TODO: new exception

        return bytes(decrypted)
776910
def decrypt(encrypted)
      fail ArgumentError, 'No cipher text supplied.' if encrypted.nil? || encrypted.empty?

      matches = CIPHER_PATTERN.match(encrypted)

      fail ArgumentError, 'Cipher text has an unsupported format.' if matches.nil?

      cipher = self.class.cipher
      cipher.decrypt
      cipher.key = Base64.decode64(@key)
      cipher.iv = Base64.decode64(matches[1])
      decrypted = cipher.update(Base64.decode64(matches[2]))

      decrypted << cipher.final
    end
1333933
function handleCipher(opts, err) {
  if (err) {
    switch (err.name) {
      case nodecipher.errors.BAD_ALGORITHM:
        handleInvalidAlgorithm(opts, err);
        break;
      case nodecipher.errors.BAD_DIGEST:
        handleInvalidHash(opts, err);
        break;
      case nodecipher.errors.BAD_FILE:
        handleEnoentError(opts, err);
        break;
      case nodecipher.errors.BAD_DECRYPT:
        handleBadDecrypt(opts, err);
        break;
      default:
        handleUnknownErrors(opts, err);
    }
    process.exit(1);
  } else {
    handleCipherSuccess(opts, err);
  }
}
267621
def decrypt(data, digest=True):
    """"""
    alg, _, data = data.rpartition("$")
    if not alg:
        return data
    data = _from_hex_digest(data) if digest else data
    try:
        return implementations["decryption"][alg](
            data, implementations["get_key"]()
        )
    except KeyError:
        raise CryptError("Can not decrypt key for algorithm: %s" % alg)
1309570
def decrypt(encoded, key: nil)

      raise ArgumentError.new('The encoded argument is required.') if encoded.blank?
      raise ArgumentError.new('The key argument is required.')     if key.blank?

      cipher = OpenSSL::Cipher::AES.new(256, 'CBC')
      cipher.decrypt
      cipher.padding = aes_256_padding
      cipher.key     = key

      cipher.update(encoded)+cipher.final

    end
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)
269851
def _extract_secrets_from_file(self, f, filename):
        
        try:
            log.info("Checking file: %s", filename)

            for results, plugin in self._results_accumulator(filename):
                results.update(plugin.analyze(f, filename))
                f.seek(0)

        except UnicodeDecodeError:
            log.warning("%s failed to load.", filename)
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:])
705429
def key_from_keyfile(keyfile):
    
    if hasattr(keyfile, 'read'):
        buf = keyfile.read()
    else:
        # Assume it is a filename and open it to read contents.
        with open(keyfile, 'rb') as fp:
            buf = fp.read()
            
    sha = SHA256.new()
    if len(buf) == 33:
        sha.update(buf)
        return sha.digest()
    elif len(buf) == 65:
        sha.update(struct.unpack('<65s', buf)[0].decode())
        return sha.digest()
    else:
        # This chunked updating of the sha is probably not really necessary
        while buf:
            if len(buf) <= 2049:
                sha.update(buf)
                buf = ''
            else:
                sha.update(buf[:2048])
                buf = buf[2048:]
        return sha.digest()
1204301
function decrypt(input, secret) {
  // Ensure we have something to decrypt
  if (!input) {
    return new Error('You must provide a value to decrypt');
  }
  // Ensure we have the secret used to encrypt this value
  if (!secret) {
    return new Error('A \'secret\' is required to decrypt');
  }

  // turn string into an object
  try {
      input = JSON.parse(input);
  } catch (err) {
      return new Error('Unable to parse string input as JSON');
  }

  // Ensure our input is a valid object with 'iv', 'salt', and 'value'
  if (!input.iv || !input.salt || !input.value) {
    return new Error('Input must be a valid object with \'iv\', \'salt\', and \'value\' properties');
  }

  var salt = new Buffer(input.salt, 'base64'),
    iv = new Buffer(input.iv, 'base64'),
    keyLength = input.keyLength,
   iterations = input.iterations;

  try {

    var key = cryptoLib.pbkdf2Sync(secret, salt, iterations, keyLength / 8, 'sha1'),
      decipher = cryptoLib.createDecipheriv(CIPHER, key, iv);

    var decryptedValue = decipher.update(input.value, 'base64', 'utf8');
    decryptedValue += decipher.final('utf8');

    return decryptedValue;

  } catch (err) {
    return new Error('Unable to decrypt value due to: ' + err);
  }
}
79792
def get_cipher_key(keyfile=None):
    
    _key = get_key(keyfile)
    _k = md5(_key).hexdigest()
    key = xor(_k[:8], _k[8:16], _k[16:24], _k[24:])
    return key
35948
public static void main(String[] args) throws Exception {
		Crypt pcf=getRandomCrypt();
		String originalPassword = "secretPassword";
		System.out.println("Original password: " + originalPassword);
		String encryptedPassword = pcf.encrypt(originalPassword);
		System.out.println("Encrypted password: " + encryptedPassword);
		String decryptedPassword = pcf.decrypt(encryptedPassword);
		System.out.println("Decrypted password: " + decryptedPassword);
	}