java实现base64加密
import java.util.base64;
public static void main(String[] args) {
String pwd = "这是加密的内容";
//base64 加密
// encodeToString 返回String
String encoded = base64.getEncoder().encodeToString(pwd.getBytes());
System.out.println(encoded);
// 返回字节
byte[] encode = base64.getEncoder().encode(pwd.getBytes());
System.out.println(encoded.toString());
byte[] decode = base64.getDecoder().decode(encode);
System.out.println(new String(decode));
//6L+Z5piv5Yqg5a+G55qE5YaF5a65
//6L+Z5piv5Yqg5a+G55qE5YaF5a65
//这是加密的内容
}
vue实现base64加密
npm install --save js-base64
- 在需要使用的页面写入,如果很多页面需要使用,可以直接在main.js中引入
let base64 = require('js-base64').base64
base64.encode(this.pwd);//加密
base64.decode(this.pwd);//解密
加密