Skip to content
This repository has been archived by the owner on Dec 23, 2020. It is now read-only.

AES Encrypt、Decrypt #142

Open
pyp163 opened this issue Aug 6, 2018 · 1 comment
Open

AES Encrypt、Decrypt #142

pyp163 opened this issue Aug 6, 2018 · 1 comment

Comments

@pyp163
Copy link

pyp163 commented Aug 6, 2018

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

@stevenroose
Copy link
Member

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants