1.如何用css js制作计算器?
2.用jQuery.md5.js加密密码后后台怎么解密?
如何用css js制作计算器?
源代码如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>js加减乘除计算器代码</title>
<style>
body,源码ul{ margin:0px; padding:0px;}
body{ background:#AF}
li{ list-style:none;}
.fl{ float:left;}
.fr{ float:right;}
.clearfix:after{ content:""; display:block;clear:both}
.clearfix{ zoom:1;}
/*是用inset可以将外部阴影改成内部阴影;若要实现内外阴影同时存在,将其并在一行用逗号隔开*/
.calBox{ width:px; padding-bottom:px;background:#FDFDFD; border-radius:5px; position:absolute; left:%; top:%; margin-left:-px; margin-top:-px; box-shadow:0px 0px px rgba(0,源码0,0,0.8),0px 0px px rgba(0,0,0,0.5) inset; -webkit-box-shadow:0px 0px px rgba(0,0,0,0.8),0px 0px px rgba(0,0,0,0.5) inset; background:#F9F9F9; overflow:hidden}
input{ width:px; height:px; margin:px 7px 0px; border-radius:5px; border:1px solid #F; box-shadow:0px 5px 2px rgba(,,,0.8) inset; -webkit-box-shadow:0px 5px 2px rgba(,,,0.8) inset; outline:none; background:#FCFDEB; text-align:right; font-family:"微软雅黑"; font-size:px; padding:0px px;}
ul{ }
li{ list-style:none; width:px; height:px; line-height:px; text-align:center; font-family:"微软雅黑"; border:1px solid #8B8B8B; border-radius:5px; background:url(/jscss/demoimg//calBg) repeat-x; float:left; margin:px 6px 0px;}
.one li{ height:px; background:url(/jscss/demoimg//calBg1.jpg) repeat-x; line-height:px;cursor:pointer;}
.one .orange{ background:url(/jscss/demoimg//calBg2.jpg) repeat-x; border:1px solid #;}
.one .black{ background:url(/jscss/demoimg//calBg3.jpg) repeat-x; border:1px solid #; color:#fff;}
.one .gray{ background:url(/jscss/demoimg//calBg4.jpg) repeat-x; border:1px solid #5F;}
.zero{ width:px;}
.one .deng{ background:url(/jscss/demoimg//calBg5.jpg); height:px;}
.twoBox{ width:px; overflow:hidden; }
.two{ width:px;}
.calBox .three { margin:0px}
.calu{ padding:0px px; width:px;}
</style>
<script type="text/javascript">
function findArr(a,c){ for(var b=0;b<a.length;b++){ if(a[b]==c){ return true}}return false}function getClass(d,f){ if(document.getElementsByClassName){ return d.getElementsByClassName(f)}else{ var a=[];var e=document.getElementsByTagName("*");for(var c=0;c<e.length;c++){ var b=e[c].className.split(" ");if(findArr(b,f)){ a.push(e[c])}}return a}};
window.onload=function()
{
var aNum=getClass(document,'num');
var oText=document.getElementById('text');
var aPer=getClass(document,'oper');
var oPer=document.getElementById('per');
var oText1=document.getElementById('text1');
var oDeng=getClass(document,'deng')[0];
var oSq=getClass(document,'sq')[0];
var oRec=getClass(document,'rec')[0];
var oZheng=getClass(document,'zheng')[0];
var oOn=getClass(document,'on')[0];
var oOff=getClass(document,'off')[0];
var oClea=getClass(document,'clea')[0];
var bOnOrOffClick=false;
function fnNum(a)
{
var bClear=false;
oText.value='0'
for(var i=0;i<aNum.length;i++)
{
aNum[i].onclick=function()
{
if(!bOnOrOffClick)return;
if(bClear)
{
bClear=false;
}
if(oText.value.indexOf('.')!=-1)
{
if(this.innerHTML=='.')
{
return;
}
}
if(oPer.value&&oText.value&&oText1.value=='')
{
oText1.value=oText.value;
oText.value='';
}
var re=/^0\.{ 1}\d+$/;
var re1=/^([0]\d+)$/;
oText.value+=this.innerHTML;
if(re.test(oText.value))
{
return;
}
if(re1.test(oText.value))
{
oText.value=this.innerHTML;
}
}
//符号部分的添加
for(var j=0;j<aPer.length;j++)
{
aPer[j].onclick=function()
{
if(oText.value&&oPer.value&&oText1.value)
{
var n=eval(oText1.value+oPer.value+oText.value);
oText.value=n;
oText1.value='';
}
oPer.value=this.innerHTML;
}
}
//点击等号的时候
oDeng.onclick=function()
{
//+-*/%的情况
if(oText1.value==''&&oPer.value==''&&oText.value=='')
{
return;
}
var n=eval(oText1.value+oPer.value+oText.value);
oText.value=n;
oText1.value='';
oPer.value='';
bClear=true;
}
//点击开根号的时候
oSq.onclick=function()
{
var m=Math.sqrt(oText.value);
oText.value=m;
}
//点击倒数的时候
oRec.onclick=function()
{
var a=1/oText.value;
if(oText.value=='0')
{
a='正无穷'
}
oText.value=a;
}
//正负号的时候
oZheng.onclick=function()
{
if(oText.value>0)
{
oText.value=-oText.value;
}
else
{
oText.value =-oText.value;
}
}
//清屏的时候
oClea.onclick=function()
{
oText.value='0';
oText1.value='';
oPer.value='';
}
}
}
//on时
oOn.onclick=function()
{
bOnOrOffClick=true;
fnNum(bOnOrOffClick);
}
//off时
oOff.onclick=function()
{
bOnOrOffClick=false;
fnNum(bOnOrOffClick);
oText.value='';
}
}
</script>
</head>
<body>
<div class="calBox">
<div class="calu">
<input type="text" id="text">
<ul class="one clearfix">
<li class="orange on">开机</li>
<li class="orange off">关机</li>
<li class="orange clea">清屏</li>
<li class="black zheng">+/-</li>
<li class="black rec">1/x</li>
<li class="num">7</li>
<li class="num">8</li>
<li class="num">9</li>
<li class="gray oper">/</li>
<li class="black oper">%</li>
<li class="num">4</li>
<li class="num">5</li>
<li class="num">6</li>
<li class="gray oper">*</li>
<li class="black sq">√</li>
<!-- -->
</ul>
<div class="clearfix">
<div class="twoBox fl">
<ul class="one fl two">
<li class="num">1</li>
<li class="num">2</li>
<li class="num">3</li>
<li class="gray oper">-</li>
<li class="zero num">0</li>
<li class="num">.</li>
<li class="gray oper">+</li>
</ul>
</div>
<ul class="one three clearfix fl">
<li class="black deng fl">=</li>
</ul>
</div>
</div>
</div>
<input type="text" id="per" style="display:none">
<input type="text" id="text1" style="display:none">
<div style="text-align:center;clear:both">
</div>
</body>
</html>
用jQuery.md5.js加密密码后后台怎么解密?
MD5不是加密算法,它是源码源码追溯奶粉Hash算法,所以它不可逆,源码也没法还原成原文。源码bitcore源码你可以用base、源码simcity 源码异或或者aes des等加密算法去实现。源码
1、源码base加密
在页面中引入base.js文件,源码调用方法为:
<!DOCTYPE HTML><html><head><meta charset="utf-8"><title>base加密</title><script type="text/javascript" src="base.js"></script><script type="text/javascript"> var b = new Base(); var str = b.encode("admin:admin"); alert("base encode:" + str);//解密 str = b.decode(str); alert("base decode:" + str);</script></head><body></body></html>2、源码md5加密
在页面中引用md5.js文件,源码调用方法为
<!DOCTYPE HTML><html><head><meta charset="utf-8"><title>md5加密</title><script type="text/ecmascript" src="md5.js"></script><script type="text/javascript"> var hash = hex_md5("dafd"); alert(hash)</script></head><body></body></html>3、源码sha1加密
据说这是源码pfring源码最安全的加密
页面中引入sha1.js,调用方法为
<!DOCTYPE HTML><html><head><meta charset="utf-8"><title>sha1加密</title><script type="text/ecmascript" src="sha1.js"></script><script type="text/javascript"> var sha = hex_sha1('mima') alert(sha)</script></head><body></body></html>一下为js们的源码源代码
base.js:
/**** Base encode / decode** @author haitao.tu* @date --* @email tuhaitao@foxmail.com**/function Base() { // private property _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/="; // public method for encoding this.encode = function (input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = _utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & ) << 2) | (chr3 >> 6); enc4 = chr3 & ; if (isNaN(chr2)) { enc3 = enc4 = ; } else if (isNaN(chr3)) { enc4 = ; } output = output + _keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4); } return output; } // public method for decoding this.decode = function (input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = _keyStr.indexOf(input.charAt(i++)); enc2 = _keyStr.indexOf(input.charAt(i++)); enc3 = _keyStr.indexOf(input.charAt(i++)); enc4 = _keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & ) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != ) { output = output + String.fromCharCode(chr2); } if (enc4 != ) { output = output + String.fromCharCode(chr3); } } output = _utf8_decode(output); return output; } // private method for UTF-8 encoding _utf8_encode = function (string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < ) { utftext += String.fromCharCode(c); } else if((c > ) && (c < )) { utftext += String.fromCharCode((c >> 6) | ); utftext += String.fromCharCode((c & ) | ); } else { utftext += String.fromCharCode((c >> ) | ); utftext += String.fromCharCode(((c >> 6) & ) | ); utftext += String.fromCharCode((c & ) | ); } } return utftext; } // private method for UTF-8 decoding _utf8_decode = function (utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < utftext.length ) { c = utftext.charCodeAt(i); if (c < ) { string += String.fromCharCode(c); i++; } else if((c > ) && (c < )) { c2 = utftext.charCodeAt(i+1); string += String.fromCharCode(((c & ) << 6) | (c2 & )); i += 2; } else { c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2); string += String.fromCharCode(((c & ) << ) | ((c2 & ) << 6) | (c3 & )); i += 3; } } return string; }}