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

AES Encrypt、Decrypt #142

Description

@pyp163

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions