Base64 encryption
This encryption is fixed encryption, a little bit insecure, you can decrypt it if you get the encrypted string
Directly on the code:
package com.zjy.knife4j.controller;
import java.io.UnsupportedEncodingException;
import java.util.Base64;
public class Test2 {
public static void main(String[] args) throws UnsupportedEncodingException {
// base64加密
String encode = Base64.getEncoder().encodeToString("王中王火腿肠".getBytes("UTF-8"));
String encode2 = Base64.getEncoder().encodeToString("中王".getBytes("UTF-8"));
System.out.println(encode);
System.out.println(encode2);
// base64解密
byte[] decode = Base64.getDecoder().decode(encode);
byte[] decode2 = Base64.getDecoder().decode(encode2);
System.out.println(new String(decode, "UTF-8"));
System.out.println(new String(decode2, "UTF-8"));
}
}
Console printing
This print result is encrypted into the same string no matter how many times it is executed. As long as you get the encrypted string, you can directly call the decryption method to get the original data. Extremely unsafe!
You can use it selectively according to your own business needs!
Welcome to the guidance of the great god, you can leave a message to communicate!
======================
My original article, reprinted to indicate the discrepancy!
=================