·用户注册
·用户登陆
·用户中心
首页
+
网络学院
+
网页特效
+
实用工具
+
网络资源
+
字体下载
+
娱乐世界
+
时尚前沿
+
图片中心
+
动漫天地
+
金石社区
图形
-
网页设计
-
优化
-
动易
-
动网
-
HTML
-
PSD
-
FLASH模板
-
插件
-
杀毒
-
系统工具
-
FLASH音乐
-
FLASH游戏
-
美女
您现在的位置:
金石网
>>
网页特效
>>
综合特效
>> 特效正文
文本加密 可自定加密code和校验码
『 更新时间:2006-4-1 』『 字体:
变小
变大
』『 作者:未知 | 来源:网络 』
把如下代码加入<body>区域中: 要完成此效果需要两个步骤 第一步:把如下代码加入到<head>区域中 <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function doSecure() { alert( 'JavaScript 1.2 or above required.' ); } function doUnsecure() { alert( 'JavaScript 1.2 or above required.' ); } // End --> </script> <script language="JavaScript1.2"> <!-- Begin function permutationGenerator(nNumElements) { this.nNumElements = nNumElements; this.antranspositions = new Array; var k = 0; for (i = 0; i < nNumElements - 1; i++) for (j = i + 1; j < nNumElements; j++) this.antranspositions[ k++ ] = ( i << 8 ) | j; // keep two positions as lo and hi byte! this.nNumtranspositions = k; this.fromCycle = permutationGenerator_fromCycle; } function permutationGenerator_fromCycle(anCycle) { var anpermutation = new Array(this.nNumElements); for (var i = 0; i < this.nNumElements; i++) anpermutation[i] = i; for (var i = 0; i < anCycle.length; i++) { var nT = this.antranspositions[anCycle[i]]; var n1 = nT & 255; var n2 = (nT >> 8) & 255; nT = anpermutation[n1]; anpermutation[n1] = anpermutation[n2]; anpermutation[n2] = nT; } return anpermutation; } function password(strpasswd) { this.strpasswd = strpasswd; this.getHashValue = password_getHashValue; this.getpermutation = password_getpermutation; } function password_getHashValue() { var m = 907633409; var a = 65599; var h = 0; for (var i = 0; i < this.strpasswd.length; i++) h = (h % m) * a + this.strpasswd.charCodeAt(i); return h; } function password_getpermutation() { var nNUMELEMENTS = 13; var nCYCLELENGTH = 21; pg = new permutationGenerator(nNUMELEMENTS); var anCycle = new Array(nCYCLELENGTH); var npred = this.getHashValue(); for (var i = 0; i < nCYCLELENGTH; i++) { npred = 314159269 * npred + 907633409; anCycle[i] = npred % pg.nNumtranspositions; } return pg.fromCycle(anCycle); } function SecureContext(strText, strSignature, bEscape) { this.strSIGNATURE = strSignature || ''; this.bESCApE = bEscape || false; this.strText = strText; this.escape = SecureContext_escape; this.unescape = SecureContext_unescape; this.transliterate = SecureContext_transliterate; this.encypher = SecureContext_encypher; this.decypher = SecureContext_decypher; this.sign = SecureContext_sign; this.unsign = SecureContext_unsign; this.secure = SecureContext_secure; this.unsecure = SecureContext_unsecure; } function SecureContext_escape(strToEscape) { var strEscaped = ''; for (var i = 0; i < strToEscape.length; i++) { var chT = strToEscape.charAt( i ); switch(chT) { case '\r': strEscaped += '\\r'; break; case '\n': strEscaped += '\\n'; break; case '\\': strEscaped += '\\\\'; break; default: strEscaped += chT; } } return strEscaped; } function SecureContext_unescape(strToUnescape) { var strUnescaped = ''; var i = 0; while (i < strToUnescape.length) { var chT = strToUnescape.charAt(i++); if ('\\' == chT) { chT = strToUnescape.charAt( i++ ); switch( chT ) { case 'r': strUnescaped += '\r'; break; case 'n': strUnescaped += '\n'; break; case '\\': strUnescaped += '\\'; break; default: // not possible } } else strUnescaped += chT; } return strUnescaped; } function SecureContext_transliterate(btransliterate) { var strDest = ''; var nTextIter = 0; var nTexttrail = 0; while (nTextIter < this.strText.length) { var strRun = ''; var cSkipped = 0; while (cSkipped < 7 && nTextIter < this.strText.length) { var chT = this.strText.charAt(nTextIter++); if (-1 == strRun.indexOf(chT)) { strRun += chT; cSkipped = 0; } else cSkipped++; } while (nTexttrail < nTextIter) { var nRunIdx = strRun.indexOf(this.strText.charAt(nTexttrail++)); if (btransliterate) { nRunIdx++ if (nRunIdx == strRun.length) nRunIdx = 0; } else { nRunIdx--; if (nRunIdx == -1) nRunIdx += strRun.length; } strDest += strRun.charAt(nRunIdx); } } this.strText = strDest; } function SecureContext_encypher(anperm) { var strEncyph = ''; var nCols = anperm.length; var nRows = this.strText.length / nCols; for (var i = 0; i < nCols; i++) { var k = anperm[ i ]; for (var j = 0; j < nRows; j++) { strEncyph += this.strText.charAt(k); k += nCols; } } this.strText = strEncyph; } function SecureContext_decypher(anperm) { var nRows = anperm.length; var nCols = this.strText.length / nRows; var anRowOfs = new Array; for (var i = 0 ; i < nRows; i++) anRowOfs[ anperm[ i ] ] = i * nCols; var strplain = ''; for (var i = 0; i < nCols; i++) { for (var j = 0; j < nRows; j++) strplain += this.strText.charAt(anRowOfs[ j ] + i); } this.strText = strplain; } function SecureContext_sign(nCols) { if (this.bESCApE) { this.strText = this.escape(this.strText); this.strSIGNATURE = this.escape(this.strSIGNATURE); } var nTextLen = this.strText.length + this.strSIGNATURE.length; var nMissingCols = nCols - (nTextLen % nCols); var strpadding = ''; if (nMissingCols < nCols) for (var i = 0; i < nMissingCols; i++) strpadding += ' '; var x = this.strText.length; this.strText += strpadding + this.strSIGNATURE; } function SecureContext_unsign(nCols) { if (this.bESCApE) { this.strText = this.unescape(this.strText); this.strSIGNATURE = this.unescape(this.strSIGNATURE); } if ('' == this.strSIGNATURE) return true; var nTextLen = this.strText.lastIndexOf(this.strSIGNATURE); if (-1 == nTextLen) return false; this.strText = this.strText.substr(0, nTextLen); return true; } function SecureContext_secure(strpasswd) { var passwd = new password(strpasswd); var anperm = passwd.getpermutation() this.sign(anperm.length); this.transliterate(true); this.encypher(anperm); } function SecureContext_unsecure(strpasswd) { var passwd = new password(strpasswd); var anperm = passwd.getpermutation() this.decypher(anperm); this.transliterate(false); return this.unsign(anperm.length); } // End --> </script> <script language="JavaScript1.2"> <!-- Begin function doSecure() { var sc = new SecureContext(document.frmSecurity.txtUnsecure.value, document.frmSecurity.txtSign.value, document.frmSecurity.chkNewLines.checked); sc.secure(document.frmSecurity.txtPassw.value); document.frmSecurity.txtSecure.value = sc.strText; document.frmSecurity.txtUnsecure.value = ''; } function doUnsecure() { var sc = new SecureContext(document.frmSecurity.txtSecure.value, document.frmSecurity.txtSign.value, document.frmSecurity.chkNewLines.checked); if (!sc.unsecure(document.frmSecurity.txtPassw.value)) alert('Invalid password used.'); document.frmSecurity.txtSecure.value = ''; document.frmSecurity.txtUnsecure.value = sc.strText; } // End --> </script> 第二步:把如下代码加入到<body>区域中 <center> <table border=1 width="571"> <tr> <td> <form name=frmSecurity> <p>密码: <input type=text name=txtPassw size=20 value="typhoon"> 可选的加密签名: <input type=text name=txtSign size=20><br> <input type=checkbox name=chkNewLines value="1"> 新算法</p> <table border=0> <tr> <td> <p align="center">待加密文本:</p> </td> <td></td> <td> <p align="center">加密后文本:</p> </td> </tr> <tr> <td> <textarea rows=4 name=txtUnsecure cols=20 wrap=virtual>Typhoon Start JavaScript Fairyland</textarea> </td> <td align=center> <input type=button value="加密>>" name=btnSecure onclick="doSecure()"> <br> <input type=button value="<< 解密" name=btnUnsecure onclick="doUnsecure()"> </td> <td><textarea rows=4 name=txtSecure cols=20 wrap=virtual></textarea></td> </tr> </table> </form> </td> </tr> </table> </center>
【点击数:】【
发表评论
】【
加入收藏
】【
告诉好友
】【
打印此文
】【
关闭窗口
】
相
关文章
您的姓名:
评分等级:
1分
2分
3分
4分
5分
评论内容:
1、严禁发表危害国家安全、政治、黄色淫秽等内容的评论。
2、用户需对自己在使用金石网服务过程中的行为承担法律责任。
3、本站管理员有权保留或删除评论内容。
4、评论内容只代表网友个人观点,与本网站立场无关。
自动显示访问者IP地址代码
3721拦截不了的弹窗代码
强制设置为主页
主页被强制修改
贪吃蛇游戏
俄罗斯方块
看谁围的圈多
射击游戏:A就是大炮
十字定全局
爱情游戏测试
网
友评论
|
设为首页
|
加入收藏
|
联系我们
|
版权申明
|
友情链接
|
站点地图
|
网站帮助
|
网站留言
|
广告服务
|
Copyright © 2001-2008
K
ings
N
et.biz All Rights Reserved. 金石工作室 版权所有