Decrypt the ciphertext with the given key.

@param ciphertext an encrypted message
@return an {@link Optional} of the original plaintext, or if either the key, nonce, or
ciphertext was modified, an empty {@link Optional}
480350
public Optional<byte[]> open(byte[] ciphertext) {
    if (ciphertext.length < SecretBox.NONCE_SIZE) {
      return Optional.empty();
    }
    final byte[] nonce = Arrays.copyOfRange(ciphertext, 0, SecretBox.NONCE_SIZE);
    final byte[] x = Arrays.copyOfRange(ciphertext, SecretBox.NONCE_SIZE, ciphertext.length);
    return box.open(nonce, x);
  }
503537
public function decrypt($cipherText = '')
    {
        $cipher = new \phpseclib\Crypt\AES();
        // could use AES::MODE_CBC
        // keys are null-padded to the closest valid size
        // longer than the longest key and it's truncated
        $cipher->setKeyLength($this->keyLength);
        $cipher->setKey($this->key);
//        $cipher->setPassword($this->key, 'pbkdf2', 'sha1', 'phpseclib/salt', 1000, 256 / 8);
        // the IV defaults to all-NULLs if not explicitly defined
        //$cipher->setIV('7014a0eb6d1611151a286c0ff4f2238f92c120d6');

        return $cipher->decrypt(base64_decode($cipherText));
    }
210697
public static String decrypt(String keyBase64, String encrypted) {
        return decrypt(Base64.decodeBase64(keyBase64.getBytes(StandardCharsets.UTF_8)), encrypted);
    }
1332533
public String decrypt(String encrypted) throws Exception {

        byte[] decodedValue = Base64Coder.decode(encrypted.toCharArray());

        Cipher c = getCipher(Cipher.DECRYPT_MODE);
        byte[] decValue = c.doFinal(decodedValue);

        return new String(decValue);
    }
1036893
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 self::ENCRYPTION_NONE:
                $decrypt = '_raw_encrypt';
                break;
            case self::ENCRYPTION_PKCS1:
                $decrypt = '_rsaes_pkcs1_v1_5_decrypt';
                break;
            //case self::ENCRYPTION_OAEP:
            default:
                $decrypt = '_rsaes_oaep_decrypt';
        }

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

        return $plaintext;
    }
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;
    }
10616
public static Cipher getCipher(final @NotNull Key key, int mode) {
        try {
            Cipher cipher = Cipher.getInstance(key.getAlgorithm());
            cipher.init(mode, key);
            return cipher;
        } catch (NoSuchAlgorithmException | InvalidKeyException | NoSuchPaddingException e) {
            throw new RuntimeException(e);
        }
    }
542871
public String encrypt(String text, PublicKey key) throws MangooEncryptionException {
        Objects.requireNonNull(text, Required.PLAIN_TEXT.toString());
        Objects.requireNonNull(text, Required.PUBLIC_KEY.toString());
        
        String encrypt = null;
        try {
            byte[] cipherText = encrypt(text.getBytes(StandardCharsets.UTF_8), key);
            encrypt = encodeBase64(cipherText);
        } catch (MangooEncryptionException e) {
            throw new MangooEncryptionException("Failed to encrypt clear text with public key", e);
        }
        
        return encrypt;
    }
1153503
public static function decrypt(
        string $ciphertext,
        SharedEncryptionKey $key
    ): string {
        $nonce = \ParagonIE_Sodium_Core_Util::substr($ciphertext, 0, 24);
        $result = \ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt(
            \ParagonIE_Sodium_Core_Util::substr($ciphertext, 24),
            $nonce,
            $nonce,
            $key->getString(true)
        );
        if (!\is_string($result)) {
            throw new InvalidMessageException('Message authentication failed.');
        }
        return $result;
    }
977210
public static final String decrypt(String secretKey, String encryptedText) {
        if (encryptedText == null) {
            return null;
        }
        if (encryptedText.startsWith("$CRYPT::")) { //$NON-NLS-1$
            byte[] decoded = Base64.decodeBase64(encryptedText.substring(8));
            Cipher cipher;
            try {
                SecretKeySpec skeySpec = keySpecFromSecretKey(secretKey);
                
                cipher = Cipher.getInstance("AES"); //$NON-NLS-1$
                cipher.init(Cipher.DECRYPT_MODE, skeySpec);
            } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException e) {
                throw new RuntimeException(e);
            }
            try {
                return new String(cipher.doFinal(decoded));
            } catch (IllegalBlockSizeException | BadPaddingException e) {
                throw new RuntimeException(e);
            }
        } else {
            return encryptedText;
        }
    }
1175429
public static String decrypt(String inputString, String encryptionPassword) {
        checkPassword(encryptionPassword);
        return getEncryptor(encryptionPassword).decrypt(inputString);
    }
1274621
public static String decode(String ciphertext, int offset) {
		final int len = ciphertext.length();
		final char[] plain = ciphertext.toCharArray();
		char c;
		for (int i = 0; i < len; i++) {
			c = ciphertext.charAt(i);
			if (false == Character.isLetter(c)) {
				continue;
			}
			plain[i] = decodeChar(c, offset);
		}
		return new String(plain);
	}
416566
def decrypt(text, key=None):
    
    if key is None:
        key = ENCRYPT_KEY

    bits = len(key)
    text = base64.b64decode(text)
    iv = text[:16]
    cipher = AES.new(key, AES.MODE_CBC, iv)
    return unpad(cipher.decrypt(text[16:]))
791759
@Override
    public Cipher decrypt() {
        try {
            Cipher cipher = Cipher.getInstance(ALGORITHM);
            cipher.init(Cipher.DECRYPT_MODE, getKey());
            return cipher;
        } catch (GeneralSecurityException e) {
            throw new AssertionError(e);
        }
    }
81904
public byte[] decryptBytes(String encryptedCredentials) {
        checkNotNull(encryptedCredentials, "encryptedCredentials");

        try {
            byte[] encryptedBytes = BaseEncoding.base64().omitPadding().decode(encryptedCredentials);
            Cipher cipher = Cipher.getInstance(CIPHER);
            cipher.init(Cipher.DECRYPT_MODE, _key, _iv);
            ByteBuffer plaintextBytes = ByteBuffer.wrap(cipher.doFinal(encryptedBytes));
            int length = plaintextBytes.getInt();
            byte[] apiKey = new byte[length];
            plaintextBytes.get(apiKey);
            return apiKey;
        } catch (Throwable t) {
            // This shouldn't happen since AES is supported by all JVMs.
            throw Throwables.propagate(t);
        }
    }
1137896
public function decrypt(string $ciphertext, string $key): string
    {
        $numMatches = preg_match_all('%^ENC\[([^,]+),(.*)\]$%', $ciphertext, $matches);
        if (0 == $numMatches) {
            throw new Exception\RuntimeException(sprintf(
                "\$ciphertext must be in the format ENC[\$encryptionType,\$ciphertext].\n"
                . "Provided ciphertext: %s",
                $ciphertext
            ));
        }

        $encryptionType = $matches[1][0];
        $ciphertext = $matches[2][0];

        switch ($encryptionType) {
            case self::ENCRYPTION_TYPE_DEFUSE_PHP_ENCRYPTION:
                $key = Key::loadFromAsciiSafeString($key);
                return Crypto::decrypt($ciphertext, $key);

            default:
                throw new Exception\RuntimeException(sprintf(
                    'Unsupported encryption type "%s". Supported encryption types: "%s".',
                    $encryptionType,
                    implode('", "', [self::ENCRYPTION_TYPE_DEFUSE_PHP_ENCRYPTION])
                ));
        }


    }
191174
public void decrypt (byte[] key)
        throws IOException, ClassNotFoundException
    {
        if (_clearCreds != null) {
            return;
        }
        _key = key;
        try {
           _contents = SecureUtil.getAESCipher(Cipher.DECRYPT_MODE, _key).doFinal(_contents);
        } catch (GeneralSecurityException gse) {
            IOException ioe = new IOException("Failed to decrypt credentials");
            ioe.initCause(gse);
            throw ioe;
        }

        ByteArrayInputStream byteIn = new ByteArrayInputStream(_contents);
        ObjectInputStream cipherIn = new ObjectInputStream(byteIn);
        _clearCreds = (Credentials)cipherIn.readObject();
    }