base64对密码进行加密和解密

时间:2024-10-13 19:06:35

1、先找到登录页面,然后再找到登录的方法。可以看到Service.asExcute('ISignOnByDWR','login' ,[{verifyCode:verifyCode,staffCode:username,password:password}]这里就是把前端的用户名密码传到后端的。不能进行密码明文传输,就要在数据交换之前进行加密。

base64对密码进行加密和解密

3、引入之后,就要对用户名,密码进行加密。var password = $.base64.encode(document.getElementById("password").value);$.base64.encode 这个就是在进行加密。

base64对密码进行加密和解密

6、decode自定义的方法。//base64解密方法 public static String decode烫喇霰嘴(String s) { byte[] b = null; String result = null; if (s != null) { BASE64Decoder decoder = new BASE64Decoder(); try { b = decoder.decodeBuffer(s); result = new String(b, "utf-8"); } catch (Exception e) { e.printStackTrace(); } } return result; }

base64对密码进行加密和解密

8、到这里加密和解密就结束了,该进行debug验证了。先看传入的用户名密码是否转码。可以看到,用户名密码都已经加密了。就这样完成了加密和解密。

base64对密码进行加密和解密
© 智德知识库