Java中的Bouncy Castle解密

Java中的Bouncy Castle解密,java,mysql,encryption,bouncycastle,Java,Mysql,Encryption,Bouncycastle,我正在使用BouncyCastle安全提供程序加密我的密码。然后将加密密码存储在数据库表中。当我从数据库中获取密码时,有人知道如何解密密码吗。这是我的示例代码,仅当它们位于一个jframe中时才起作用 public String encrypt(String textToEncrypt) { String encryptedpassword = null; try { Security.addProvider(new org.bouncycastle.jce.p

我正在使用BouncyCastle安全提供程序加密我的密码。然后将加密密码存储在数据库表中。当我从数据库中获取密码时,有人知道如何解密密码吗。这是我的示例代码,仅当它们位于一个jframe中时才起作用

 public String encrypt(String textToEncrypt) {
    String encryptedpassword = null;
    try {
        Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
        password1 = textToEncrypt.getBytes();
        SecretKeySpec key = new SecretKeySpec(keyBytes, "DES");
        IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
        cipherpass = Cipher.getInstance("DES/CTR/NoPadding", "BC");
        cipherpass.init(Cipher.ENCRYPT_MODE, key, ivSpec);
        cipherTextPassword = new byte[cipherpass.getOutputSize(password1.length)];
        passLength = cipherpass.update(password1, 0, password1.length, cipherTextPassword, 0);
        passLength += cipherpass.doFinal(cipherTextPassword, passLength);
        encryptedpassword = new String(cipherTextPassword);
    } catch (NoSuchAlgorithmException | NoSuchProviderException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | ShortBufferException | IllegalBlockSizeException | BadPaddingException ex) {

    }
    return encryptedpassword;
}
 byte[] password1;
byte[] emailpass1;
byte[] keyBytes = "12345678".getBytes();
byte[] ivBytes = "input123".getBytes();
SecretKeySpec key = new SecretKeySpec(keyBytes, "DES");
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
Cipher cipherEmailpass, cipherpass;
byte[] cipherTextPassword;
byte[] cipherEmailTextPassword;
int passLength, emailpassLength;

你的问题是什么?我想要一个解密函数来解密加密密码你的问题是什么?我想要一个解密函数来解密加密密码你的问题是什么?我想要一个解密函数来解密加密密码