本文目錄一覽:
- 1、web端調接口用angularJS的post請求,接口傳輸數據一般用什麼加密方式呀?要後台java那邊可逆的。
- 2、誰有用js加密,用java對應解密的 源代碼
- 3、Java,JS如何不讓瀏覽器自動記住密碼
web端調接口用angularJS的post請求,接口傳輸數據一般用什麼加密方式呀?要後台java那邊可逆的。
一、平常使用的post提交和接收方式
前端使用jquery提交數據。
?
1
2
3
4
5
6
7
8
9
$.ajax({
url:’/carlt/loginForm’,
method: ‘POST’,
data:{“name”:”jquery”,”password”:”pwd”},
dataType:’json’,
success:function(data){
//…
}
});
後端java接收:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
@Controller
public class UserController {
@ResponseBody
@RequestMapping(value=”/loginForm”,method=RequestMethod.POST)
public User loginPost(User user){
System.out.println(“username:”+user.getName());
System.out.println(“password:”+user.getPassword());
return user;
}
}
model(不要忘記get、set方法):
public class User {
private String name;
private String password;
private int age;
//setter getter method
}
誰有用js加密,用java對應解密的 源代碼
script language=”javascript”
var str;
function showUnico(){
if(document.getElementById(“before”).value.length 0){
str = escape(document.getElementById(“before”).value);
document.getElementById(“after”).value = str;
}
else alert(“請輸入要加密的代碼”);
}
function showHtml(){
if(document.getElementById(“after”).value.length 0){
str = unescape(document.getElementById(“after”).value);
document.getElementById(“before”).value = str;
}
else alert(“請輸入要解密的代碼”);
}
function clearBoth(){
document.getElementById(“before”).value = “”;
document.getElementById(“after”).value = “”;
}
/script
body
center
table
tr
th加密前/th
th加密後/th
/tr
tr
td
textarea id=”before” style=”width: 200px; height: 174px”/textarea
/td
td
textarea id=”after” style=”width: 200px; height: 174px”/textarea
/td
/tr
/table
br
input type=”button” value=”加密” onclick=”showUnico()”
input type=”button” value=”解密” onclick=”showHtml()”
input type=”button” value=”全部清空” onclick=”clearBoth()”
/center
/body
Java,JS如何不讓瀏覽器自動記住密碼
1、JS清空cookies。具體方法不在此介紹了。
2、登錄時採用https協議。
3、設置上autocomplete屬性,阻止瀏覽器從cookies獲取數據填充登錄表單:
input type=”text” id=”username” name=”username” autocomplete=”off”/
input type=”password” id=”password” autocomplete=”off”/
4、在獲取焦點時再改變類型:
一般我們都是將密碼框類型設置為『password』,現在我們將它改為『text』,在獲取焦點後再改變它的類型。
input type=”text” id=”password” onfocus=”this.type=’password'” /
5、再者就是:
input type=”text” id=”password” onfocus=”this.type=’password'” autocomplete=”off”/
6、安裝加密控件,類似於支付寶那種加密方式。
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/199939.html