首页 > 编程知识 正文

java和js加密方式有哪些(java中加密方式有哪些)

时间:2023-12-23 11:38:06 阅读:319289 作者:KECG

本文目录一览:

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、安装加密控件,类似于支付宝那种加密方式。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。