public class DecryAndEncryTest {
/**
* /密码加密
* @return
*/
@Test
public void encryptByBase() {
Base64.Encoder encoder = Base64.getEncoder();
byte[] passbyte = null;
String pwd = "yss";
try {
passbyte = pwd.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String encodedpass = encoder.encodeToString(passbyte);
System.out.println(encodedpass);
}
/**
* /解密
* @return
*/
@Test
public void dncryptByBase() {
Base64.Decoder decoder = Base64.getDecoder();
byte[] passbyte = decoder.decode("eXNz");
String pass = new String(passbyte);
System.out.println(pass);
}
}
还没有评论,来说两句吧...