PHP服务器端加密,javascript客户端解密
来源:互联网 发布:休闲网游 知乎 编辑:程序博客网 时间:2024/04/27 15:04
有时需要对客户端的输出的一些内容加密,但在页面脚本中又需要用到这些内容,找了些代码,测试可以。但不支持中文。一般简单加密还是OK的。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<script type="text/javascript">
<!--
function strencode(string) {
key = '123456';
string = base64_decode(string);
len = key.length;
code = '';
for (i = 0; i < string.length; i++) {
k = i % len;
code += String.fromCharCode(string.charCodeAt(i) ^ key.charCodeAt(k));
}
return base64_decode(code);
}
function base64_decode (data) {
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
ac = 0,
dec = "",
tmp_arr = [];
if (!data) {
return data;
}
data += '';
do { // unpack four hexets into three octets using index points in b64
h1 = b64.indexOf(data.charAt(i++));
h2 = b64.indexOf(data.charAt(i++));
h3 = b64.indexOf(data.charAt(i++));
h4 = b64.indexOf(data.charAt(i++));
bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
o1 = bits >> 16 & 0xff;
o2 = bits >> 8 & 0xff;
o3 = bits & 0xff;
if (h3 == 64) {
tmp_arr[ac++] = String.fromCharCode(o1);
} else if (h4 == 64) {
tmp_arr[ac++] = String.fromCharCode(o1, o2);
} else {
tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
}
} while (i < data.length);
dec = tmp_arr.join('');
return dec;
}
//-->
</script>
<?php
function strencode($string) {
$string = base64_encode ( $string );
$key = '123456';
$len = strlen ( $key );
$code = '';
for($i = 0; $i < strlen ( $string ); $i ++) {
$k = $i % $len;
$code .= $string [$i] ^ $key [$k];
}
return base64_encode ( $code );
}
?>
<input type="button" value="Click me" onclick="javascript:alert(strencode('<?php echo strencode("http://www.ssejej.com/aASaa.php?333") ?>'));" >
</body>
</html>
- PHP服务器端加密,javascript客户端解密
- php服务器端加密+delphi客户端加密
- 加密解密算法,客户端C++加密,服务端PHP解密
- android(客户端)和PC(服务器端)通信RSA 加密解密
- android、ios与服务器端php使用rsa加密解密通讯
- android、ios与服务器端php使用rsa加密解密通讯
- android、ios与服务器端php使用rsa加密解密通讯
- android、ios与服务器端php使用rsa加密解密通讯
- android、ios与服务器端php使用rsa加密解密通讯
- android、ios与服务器端php使用rsa加密解密通讯
- android、ios与服务器端php使用rsa加密解密通讯
- android、ios与服务器端php使用rsa加密解密通讯
- android、ios与服务器端php使用rsa加密解密通讯
- android、ios与服务器端php使用rsa加密解密通讯
- android、ios与服务器端php使用rsa加密解密通讯
- android、ios与服务器端php使用rsa加密解密通讯
- PHP加密函数 Javascript/Js 解密函数
- rsa非对称加解密,java服务器端对应android、IOS客户端以及javaScript的加解密
- 顺序表(学习笔记)
- 语言学基础 01
- Linux
- MySQL游标
- java7新特性--------final重抛
- PHP服务器端加密,javascript客户端解密
- 数学与信息论 基础
- 欧行漫记:参观华为欧洲研究所,感受华为海外研发人员的苦乐人生
- Oracle10g卸载-Win7
- 【学习笔记⑥】ssh中利用struts实现图片的上传功能
- 若不符合DML触发器的块中的条件--抛出异常
- Banner Grabbing: Enumeration & Exploitation
- OpenSSL命令---s_server
- perl中变量的限定