Decrypting in Java with Blowfish

后端 未结 6 1997
独厮守ぢ
独厮守ぢ 2021-02-06 18:41

Hullo,

I am encrypting and decrypting in Java with Blowfish.

The encryption works fine, but the decryption fails.

Here is my Java code for decrypting :

6条回答
  •  没有蜡笔的小新
    2021-02-06 19:18

    Try this

    private byte[] encrypt(String key, String plainText) throws GeneralSecurityException {
    
        SecretKey secret_key = new SecretKeySpec(key.getBytes(), ALGORITM);
    
        Cipher cipher = Cipher.getInstance(ALGORITM);
        cipher.init(Cipher.ENCRYPT_MODE, secret_key);
    
        return cipher.doFinal(plainText.getBytes());
    }
    

    here you can find whole class with enc/dec --- http://dexxtr.com/post/57145943236/blowfish-encrypt-and-decrypt-in-java-android

提交回复
热议问题