Decrypts the private key with given password.
Does nothing if the key is not encrypted.

@param password password to decrypt the key with.
@throws GeneralSecurityException whenever an error occurs during decryption.
165132
public void decrypt(byte[] password) throws GeneralSecurityException {
        if (!isEncrypted()) {
            return;
        }

        byte[] enc = Base64.decode(this.encodedKey);

        SecretKeySpec key = getSecretKey(password, this.initializationVector.getIV());

        Cipher cipher = getCipher();
        cipher.init(Cipher.DECRYPT_MODE, key, this.initializationVector);
        enc = cipher.doFinal(enc);

        this.intKey = getKey(this.keyAlg, enc);
        this.keyData = enc;
        this.isEncrypted = false;
        this.encodedKey = null;
    }
112114
public String decrypt(String message) throws GeneralSecurityException {
		byte[] bytes = Base64.getDecoder().decode(message);
		return new String(encryptor.decrypt(bytes));
	}
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);
    }
523213
public String decrypt(String cipherText) throws MissingParameterException {

		if (StringUtils.isBlank(cipherText)) {
			throw new MissingParameterException("Missing parameter: cipherText");
		}

		return stringEncryptor.decrypt(cipherText);
	}
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);
        }
    }
614155
public static byte[] decryptBytes (PrivateKey key, byte[] encrypted, byte[] salt)
    {
        try {
            byte[] decrypted = getRSACipher(key).doFinal(encrypted);
            for (int ii = 0; ii < salt.length; ii++) {
                if (decrypted[decrypted.length - salt.length + ii] != salt[ii]) {
                    return null;
                }
            }
            byte[] secret = new byte[decrypted.length - salt.length];
            for (int ii = 0; ii < secret.length; ii++) {
                secret[ii] = decrypted[ii];
            }
            return secret;
        } catch (GeneralSecurityException gse) {
            log.warning("Failed to decrypt bytes", gse);
        }
        return null;
    }
989972
public static void decryptAsync(String encrypted, String password, RNCryptorNativeCallback RNCryptorNativeCallback) {
        String decrypted;
        try {
            decrypted = new RNCryptorNative().decrypt(encrypted, password);
            RNCryptorNativeCallback.done(decrypted, null);
        } catch (Exception e) {
            RNCryptorNativeCallback.done(null, e);
        }
    }
625591
@Restricted(NoExternalUse.class) // TODO pending API
    public Cipher encrypt(byte[] iv) {
        try {
            Cipher cipher = Secret.getCipher(ALGORITHM);
            cipher.init(Cipher.ENCRYPT_MODE, getKey(), new IvParameterSpec(iv));
            return cipher;
        } catch (GeneralSecurityException e) {
            throw new AssertionError(e);
        }
    }
962440
static public byte[] getPreNTLMResponse ( CIFSContext tc, String password, byte[] challenge ) throws GeneralSecurityException {
        byte[] p14 = new byte[14];
        byte[] p21 = new byte[21];
        byte[] p24 = new byte[24];
        byte[] passwordBytes = Strings.getOEMBytes(password, tc.getConfig());
        int passwordLength = passwordBytes.length;

        // Only encrypt the first 14 bytes of the password for Pre 0.12 NT LM
        if ( passwordLength > 14 ) {
            passwordLength = 14;
        }
        System.arraycopy(passwordBytes, 0, p14, 0, passwordLength);
        NtlmUtil.E(p14, NtlmUtil.S8, p21);
        NtlmUtil.E(p21, challenge, p24);
        return p24;
    }
480515
public String encrypt(String message) throws GeneralSecurityException {
		byte[] bytes = encryptor.encrypt(message.getBytes());
		return Base64.getEncoder().encodeToString(bytes);
	}
1261245
public void setPassword(CharSequence password) {

        LettuceAssert.notNull(password, "Password must not be null");
        this.password = password.toString().toCharArray();
    }
210697
public static String decrypt(String keyBase64, String encrypted) {
        return decrypt(Base64.decodeBase64(keyBase64.getBytes(StandardCharsets.UTF_8)), encrypted);
    }
1003183
public void setKeyManagerFactoryKeyStorePassword(String password) {
        if (password != null) {
            this.keyManagerFactoryKeyStorePassword = password.toCharArray();
        } else {
            this.keyManagerFactoryKeyStorePassword = null;
        }
    }
1116200
protected void initialize() throws GeneralSecurityException {
		if(keyPair == null) {
			keyPair = createKeyPair();
		}
		keyAgreement.init(keyPair.getPrivate());
	}
560380
public static String getCryptoAlgorithm(String password) {
        if (null == password) {
            return null;
        }
        String algorithm = null;
        String data = password.trim();

        if (data.length() >= 2) {
            if ('{' == data.charAt(0)) {
                int end = data.indexOf('}', 1);
                if (end > 0) {
                    algorithm = data.substring(1, end).trim();
                }
            }
        }

        return algorithm;
    }
823389
public void decrypt(File src, File dest) throws GeneralSecurityException, IOException {
		InputStream is = null;
		OutputStream os = null;
		try {
			is = encryptor.wrapInputStream(new FileInputStream(src));
			os = new FileOutputStream(dest);
			copy(is, os);
		} finally {
			if(is != null) {
				is.close();
			}
			if(os != null) {
				os.close();
			}
		}
	}
120988
private String decryptInternal(SecretKeySpec key, byte[] encryptedBytes) {
        try {
            Cipher cipher = Cipher.getInstance(ENCRYPTION_ALGORITHM + ENCRYPTION_ALGORITHM_MODIFIER);
            cipher.init(Cipher.DECRYPT_MODE, key);
            byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
            return new String(decryptedBytes, ENCODING);
        } catch (GeneralSecurityException e) {
            throw new RuntimeException("Exception during decryptInternal: " + e, e);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("Exception during encryptInternal: " + e, e);
        }
    }