public class text {
static final byte[] bytes_a = new byte[]{66, 108, 111, 119, 102, 105, 115, 104};
static final byte[] bytes_key = new byte[]{104,101,108,108,111,50,48,49,55};
static final byte[] bytes_content = new byte[]{103,111,111,100,32,106,111,98,32,77,121,32,102,114,105,101,110,100};
public static void main(String[] args) {
SecretKeySpec se_key = new SecretKeySpec(bytes_key,new String(bytes_a));
byte[] target = encrypt(se_key,bytes_content);
System.out.println(new String(target));
byte[] bytes = decrypt(se_key,target);
System.out.println(new String(bytes));
}
public static byte[] encrypt(Key key, byte[] text){
try {
Cipher cipher = Cipher.getInstance(new String(bytes_a));
cipher.init(Cipher.ENCRYPT_MODE,key);
return cipher.doFinal(text);
} catch (NoSuchAlgorithmException e) {
e.pr
加密算法
最新推荐文章于 2021-11-21 09:23:49 发布