PointyCastle/pointycastle

AES Encrypt、Decrypt

Opened this issue · 1 comments

public static String aesEncrypt(String data, String key) {
try {

       String spec = key.substring(0, 16);
        SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(), "AES");
        Cipher cipher = Cipher.getInstance("AES/CFB/NoPadding");
        IvParameterSpec iv = new IvParameterSpec(spec.getBytes());
        cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
        byte[] bytes = cipher.doFinal(data.getBytes("UTF-8"));
        return new String(Base64.encode(bytes));
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

}

有没有能解决这样的加解密的例子?
Are there any examples of encryption and decryption that can be solved?
我找了很久都没有找一个能解决问题的例子
I've been looking for a long time without finding an example to solve the problem

Please take a look at this example and let me know if it works for you: #111