文本加密解密

2016-02-19 12:52 1 1 收藏

下面是个简单易学的文本加密解密教程,图老师小编详细图解介绍包你轻松学会,喜欢的朋友赶紧get起来吧!

【 tulaoshi.com - Web开发 】

第一步:把如下代码加入到head区域中

SCRIPT LANGUAGE="JavaScript"
!-- Begin
function Encrypt(theText) {
output = new String;
Temp = new Array();
Temp2 = new Array();
TextSize = theText.length;
for (i = 0; i TextSize; i++) {
rnd = Math.round(Math.random() * 122) + 68;
Temp[i] = theText.charCodeAt(i) + rnd;
Temp2[i] = rnd;
}
for (i = 0; i TextSize; i++) {
output += String.fromCharCode(Temp[i], Temp2[i]);
}
return output;
}
function unEncrypt(theText) {
output = new String;
Temp = new Array();
Temp2 = new Array();
TextSize = theText.length;
for (i = 0; i TextSize; i++) {
Temp[i] = theText.charCodeAt(i);
Temp2[i] = theText.charCodeAt(i + 1);
}
for (i = 0; i TextSize; i = i+2) {
output += String.fromCharCode(Temp[i] - Temp2[i]);
}
return output;
}
//  End --
/script

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)


第二步:把如下代码加入到body区域中

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

center
form name=encform onsubmit="return false;"
    textarea name=box1 rows=5 cols=50Typhoon Start JavaScript Fairyland

来源:https://www.tulaoshi.com/n/20160219/1602242.html

延伸阅读
加密和解密的字符串: 代码如下: package eoe.demo; import java.security.SecureRandom; import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; /** * Usage: * pre * String crypto = SimpleCrypto.encrypt(masterpassword, cleartext) * ......
Private Function EncryptString(strString) Dim CharHexSet, intStringLen, strTemp, strRAW, i, intKey, intOffSet Randomize Timer intKey = Round((RND * 1000000) + 1000000) '##### Key Bitsize intOffSet = Round((RND * 1000000) + 1000000) '##### KeyOffSet Bitsize If IsNull(strString) = False Then strRAW = strString intS...
标签: PHP
<?php   $key = "This is supposed to be a secret key !!!";   function keyED($txt,$encrypt_key)   {   $encrypt_key = md5($encrypt_key);   $ctr=0;   $tmp = "";   for ($i=0;$i<strlen($txt);$i++)   { ...
using System; using System.IO; using System.Security.Cryptography; namespace Vavic { /// /// Security 的摘要说明。 /// public class Security { const string KEY_64 = "VavicApp"; const string IV_64 = "VavicApp"; //注意了,是8个字符,64位 public Security() { // // TODO: 在此处添加构造函数逻辑 // } publ...
.NET将原来独立的API和SDK合并到一个框架中,这对于程序开发人员非常有利。它将CryptoAPI改编进.NET的System.Security.Cryptography名字空间,使密码服务摆脱了SDK平台的神秘性,变成了简单的.NET名字空间的使用。由于随着整个框架组件一起共享,密码服务更容易实现了,现在仅仅需要学习System.Security.Cryptography名字空间的功能和用于解决...

经验教程

392

收藏

67
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部