Decrypt an encrypted string
544586
function decrypt (str) {
    var decipher = crypto.createDecipher(algorithm, key)
      , dec = decipher.update(str, to, from) + decipher.final(from)
    return dec;
  }
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)
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
849581
protected function decrypt(string $string)
    {
        $pri_key = openssl_pkey_get_private($this->getRsaKey($this->pri_key));

        $length = openssl_pkey_get_details($pri_key)['bits'];

        $splits = str_split(base64_decode($string), $length / 8);

        $decryptedString = '';

        foreach ($splits as $split) {
            openssl_private_decrypt($split, $decrypted, $pri_key);
            $decryptedString .= $decrypted;
        }

        return $decryptedString;
    }
21863
function decrypt($encryptedText)
    {
        $parts = explode(':', $encryptedText);

        if (count($parts) != 2) {
            throw new DecryptionException();
        }

        $main = base64_decode($parts[0]);
        $iv = base64_decode($parts[1]);
        return openssl_decrypt($main, $this->method, $this->key, $this->options, $iv);
    }
311854
def Decrypt(self, encrypted_data):
    
    index_split = -(len(encrypted_data) % AES.block_size)
    if index_split:
      remaining_encrypted_data = encrypted_data[index_split:]
      encrypted_data = encrypted_data[:index_split]
    else:
      remaining_encrypted_data = b''

    decrypted_data = self._aes_cipher.decrypt(encrypted_data)

    return decrypted_data, remaining_encrypted_data
116373
public static String decrypt(String encrypted) {
        try {
            return decrypt(encrypted, null);
        } catch (GeneralSecurityException e) {
            e.printStackTrace();
            return null;
        }
    }
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))
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)
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:]))
1017819
function decrypt($ciphertext)
    {
        $this->_setup();

        if ($this->paddable) {
            // we pad with chr(0) since that's what mcrypt_generic does.  to quote from http://php.net/function.mcrypt-generic :
            // "The data is padded with "\0" to make sure the length of the data is n * blocksize."
            $ciphertext = str_pad($ciphertext, strlen($ciphertext) + ($this->block_size - strlen($ciphertext) % $this->block_size) % $this->block_size, chr(0));
        }

        $block_size = $this->block_size;
        $buffer = &$this->debuffer;
        $continuousBuffer = $this->continuousBuffer;
        $plaintext = '';
        switch ($this->mode) {
            case CRYPT_RIJNDAEL_MODE_ECB:
                for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
                    $plaintext.= $this->_decryptBlock(substr($ciphertext, $i, $block_size));
                }
                break;
            case CRYPT_RIJNDAEL_MODE_CBC:
                $xor = $this->decryptIV;
                for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
                    $block = substr($ciphertext, $i, $block_size);
                    $plaintext.= $this->_decryptBlock($block) ^ $xor;
                    $xor = $block;
                }
                if ($this->continuousBuffer) {
                    $this->decryptIV = $xor;
                }
                break;
            case CRYPT_RIJNDAEL_MODE_CTR:
                $xor = $this->decryptIV;
                if (!empty($buffer['ciphertext'])) {
                    for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
                        $block = substr($ciphertext, $i, $block_size);
                        $buffer['ciphertext'].= $this->_encryptBlock($this->_generate_xor($block_size, $xor));
                        $key = $this->_string_shift($buffer['ciphertext'], $block_size);
                        $plaintext.= $block ^ $key;
                    }
                } else {
                    for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
                        $block = substr($ciphertext, $i, $block_size);
                        $key = $this->_encryptBlock($this->_generate_xor($block_size, $xor));
                        $plaintext.= $block ^ $key;
                    }
                }
                if ($this->continuousBuffer) {
                    $this->decryptIV = $xor;
                    if ($start = strlen($ciphertext) % $block_size) {
                        $buffer['ciphertext'] = substr($key, $start) . $buffer['encrypted'];
                    }
                }
                break;
            case CRYPT_RIJNDAEL_MODE_CFB:
                if (!empty($buffer['ciphertext'])) {
                    $plaintext = $ciphertext ^ substr($this->decryptIV, strlen($buffer['ciphertext']));
                    $buffer['ciphertext'].= substr($ciphertext, 0, strlen($plaintext));
                    if (strlen($buffer['ciphertext']) == $block_size) {
                        $xor = $this->_encryptBlock($buffer['ciphertext']);
                        $buffer['ciphertext'] = '';
                    }
                    $start = strlen($plaintext);
                    $block = $this->decryptIV;
                } else {
                    $plaintext = '';
                    $xor = $this->_encryptBlock($this->decryptIV);
                    $start = 0;
                }

                for ($i = $start; $i < strlen($ciphertext); $i+=$block_size) {
                    $block = substr($ciphertext, $i, $block_size);
                    $plaintext.= $block ^ $xor;
                    if ($continuousBuffer && strlen($block) != $block_size) {
                        $buffer['ciphertext'].= $block;
                        $block = $xor;
                    } else if (strlen($block) == $block_size) {
                        $xor = $this->_encryptBlock($block);
                    }
                }
                if ($this->continuousBuffer) {
                    $this->decryptIV = $block;
                }
                break;
            case CRYPT_RIJNDAEL_MODE_OFB:
                $xor = $this->decryptIV;
                if (strlen($buffer)) {
                    for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
                        $xor = $this->_encryptBlock($xor);
                        $buffer.= $xor;
                        $key = $this->_string_shift($buffer, $block_size);
                        $plaintext.= substr($ciphertext, $i, $block_size) ^ $key;
                    }
                } else {
                    for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
                        $xor = $this->_encryptBlock($xor);
                        $plaintext.= substr($ciphertext, $i, $block_size) ^ $xor;
                    }
                    $key = $xor;
                }
                if ($this->continuousBuffer) {
                    $this->decryptIV = $xor;
                    if ($start = strlen($ciphertext) % $block_size) {
                         $buffer = substr($key, $start) . $buffer;
                    }
                }
        }

        return $this->paddable ? $this->_unpad($plaintext) : $plaintext;
    }
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)
38637
function decrypt($enc_string,$base64_decode=true){
		if(is_null($enc_string) || empty($enc_string)) return NULL;
		if(!$this->verified) $this->verify();
		//decrypt and return
		if($base64_decode) $enc_string = base64_decode($enc_string);
		$plain_string = mcrypt_decrypt(
			 self::$crypt_cipher
			,base64_decode($this->key)
			,$enc_string
			,self::$crypt_mode
			,base64_decode($this->iv)
		);
		//get size of string from atom
		$size = unpack('N',substr($plain_string,0,4));
		$size = array_shift($size);
		//make sure we have the original string
		$plain_string = substr($plain_string,4,$size);
		return $plain_string;
	}
1098183
function decrypt($ciphertext)
    {
        if ($this->k <= 0) {
            return false;
        }

        $ciphertext = str_split($ciphertext, $this->k);
        $ciphertext[count($ciphertext) - 1] = str_pad($ciphertext[count($ciphertext) - 1], $this->k, chr(0), STR_PAD_LEFT);

        $plaintext = '';

        switch ($this->encryptionMode) {
            case CRYPT_RSA_ENCRYPTION_NONE:
                $decrypt = '_raw_encrypt';
                break;
            case CRYPT_RSA_ENCRYPTION_PKCS1:
                $decrypt = '_rsaes_pkcs1_v1_5_decrypt';
                break;
            //case CRYPT_RSA_ENCRYPTION_OAEP:
            default:
                $decrypt = '_rsaes_oaep_decrypt';
        }

        foreach ($ciphertext as $c) {
            $temp = $this->$decrypt($c);
            if ($temp === false) {
                return false;
            }
            $plaintext.= $temp;
        }

        return $plaintext;
    }
108932
public static String decrypt(String str) {
	if (StringUtil.isEmpty(str) || !StringUtil.startsWithIgnoreCase(str, "encrypted:")) return str;
	str = str.substring(10);
	return new BlowfishEasy("sdfsdfs").decryptString(str);
    }
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);
  }
}
269582
def decrypt_text(self, text, *args, **kwargs):
        
        b = text.encode("utf-8")
        token = base64.b64decode(b)
        return self.decrypt(token, *args, **kwargs).decode("utf-8")