用jQuery.md5.js加密密码后后台怎么解密?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用jQuery.md5.js加密密码后后台怎么解密?相关的知识,希望对你有一定的参考价值。

MD5不是加密算法,它是Hash算法,所以它不可逆,也没法还原成原文。
你可以用base64、异或或者aes des等加密算法去实现。

1、base64加密

在页面中引入base64.js文件,调用方法为:

?

123456789101112131415161718

<!DOCTYPE html><html><head><meta charset="utf-8"><title>base64加密</title><script type="text/javascript" src="base64.js"></script><script type="text/javascript">  var b = new Base64();  var str = b.encode("admin:admin");  alert("base64 encode:" + str);//解密  str = b.decode(str);  alert("base64 decode:" + str);</script></head><body></body></html>

2、md5加密

在页面中引用md5.js文件,调用方法为

?

1234567891011121314

<!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("123dafd"); alert(hash)</script></head><body></body></html>

3、sha1加密

据说这是最安全的加密

页面中引入sha1.js,调用方法为

?

1234567891011121314

<!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('mima123465') alert(sha)</script></head><body></body></html>

一下为js们的源代码

base64.js:

?

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106

/**** Base64 encode / decode** @author haitao.tu* @date 2010-04-26* @email tuhaitao@foxmail.com**/function Base64()  // private property _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; // 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 & 15) << 2) | (chr3 >> 6);   enc4 = chr3 & 63;   if (isNaN(chr2))     enc3 = enc4 = 64;    else if (isNaN(chr3))     enc4 = 64;      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 & 15) << 4) | (enc3 >> 2);   chr3 = ((enc3 & 3) << 6) | enc4;   output = output + String.fromCharCode(chr1);   if (enc3 != 64)     output = output + String.fromCharCode(chr2);      if (enc4 != 64)     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 < 128)     utftext += String.fromCharCode(c);    else if((c > 127) && (c < 2048))     utftext += String.fromCharCode((c >> 6) | 192);    utftext += String.fromCharCode((c & 63) | 128);    else     utftext += String.fromCharCode((c >> 12) | 224);    utftext += String.fromCharCode(((c >> 6) & 63) | 128);    utftext += String.fromCharCode((c & 63) | 128);       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 < 128)     string += String.fromCharCode(c);    i++;    else if((c > 191) && (c < 224))     c2 = utftext.charCodeAt(i+1);    string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));    i += 2;    else     c2 = utftext.charCodeAt(i+1);    c3 = utftext.charCodeAt(i+2);    string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));    i += 3;       return string; 

参考技术A

MD5 加密是不可逆的吧 判断用户的时候也是把他密码加密后和数据库里的比较 一样的话就是正确的

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title></title> 
<script type="text/javascript" src="Scripts/jquery-1.3.2.min.js"></script> 
<script type="text/javascript" src="Scripts/jquery.md5.js"></script> 
<script type="text/javascript"> 
alert($.md5("Hello")); 
</script> 
</head> 
<body> 
</body> 
</html>

凯撒密码实现英文短句的加解密

参考技术A

1. 将“We are students.”这个英文词句用k=4的凯萨密码翻译成密码

1. 恺撒密码,

作为一种最为古老的对称加密体制,他的基本思想是:

通过把字母移动一定的位数来实现加密和解密。

例如,如果密匙是把明文字母的位数向后移动三位,那么明文字母B就变成了密文的E,依次类推,X将变成A,Y变成B,Z变成C,由此可见,位数就是凯撒密码加密和解密的密钥。

如:ZHDUHVWXGHQWV(后移三位)

2. 凯撒密码,

是计算机C语言编程实现加密和解密。挺复杂的。你可以研究一下哦。

2. 将凯撒密码(K=7)的加密、解密过程用C语言编程实现

/*

声明:MSVC++6.0环境测试通过

*/

#include<stdio.h>

#include<ctype.h>

#define maxlen 100

#define K 7

char *KaisaEncode(char *str)//加密

char *d0;

d0=str;

for(;*str!=\'\\0\';str++)

if(isupper(*str))

*str=(*str-\'A\'+K)%26+\'A\';

else if(islower(*str))

*str=(*str-\'a\'+K)%26+\'a\';

else

continue;

return d0;

char *KaisaDecode(char *str)//解密

char *d0;

d0=str;

for(;*str!=\'\\0\';str++)

if(isupper(*str))

*str=(*str-\'A\'-K+26)%26+\'A\';

else if(islower(*str))

*str=(*str-\'a\'-K+26)%26+\'a\';

else

continue;

return d0;

int main(void)

char s[maxlen];

gets(s);

puts(KaisaEncode(s));

puts(KaisaDecode(s));

return 0;

3. 将凯撒密码X的加密、解密过程用C语言编程实现

(2)kaiser加密算法 具体程序:#include #include char encrypt(char ch,int n)/*加密函数,把字符向右循环移位n*/ while(ch>=\'A\'&&ch=\'a\'&&ch<=\'z\') return (\'a\'+(ch-\'a\'+n)%26); return ch; void menu()/*菜单,1.加密,2.解密,3.暴力破解,密码只能是数字*/ clrscr(); printf("\\n========================================================="); printf("\\n1.Encrypt the file"); printf("\\n2.Decrypt the file"); printf("\\n3.Force decrypt file"); printf("\\n4.Quit\\n"); printf("=========================================================\\n"); printf("Please select a item:"); return; main() int i,n; char ch0,ch1; FILE *in,*out; char infile[20],outfile[20]; textbackground(BLACK); textcolor(LIGHTGREEN); clrscr(); sleep(3);/*等待3秒*/ menu(); ch0=getch(); while(ch0!=\'4\') if(ch0==\'1\') clrscr(); printf("\\nPlease input the infile:"); scanf("%s",infile);/*输入需要加密的文件名*/ if((in=fopen(infile,"r"))==NULL) printf("Can not open the infile!\\n"); printf("Press any key to exit!\\n"); getch(); exit(0); printf("Please input the key:"); scanf("%d",&n);/*输入加密密码*/ printf("Please input the outfile:"); scanf("%s",outfile);/*输入加密后文件的文件名*/ if((out=fopen(outfile,"w"))==NULL) printf("Can not open the outfile!\\n"); printf("Press any key to exit!\\n"); fclose(in); getch(); exit(0); while(!feof(in))/*加密*/ fputc(encrypt(fgetc(in),n),out); printf("\\nEncrypt is over!\\n"); fclose(in); fclose(out); sleep(1); if(ch0==\'2\') clrscr(); printf("\\nPlease input the infile:"); scanf("%s",infile);/*输入需要解密的文件名*/ if((in=fopen(infile,"r"))==NULL) printf("Can not open the infile!\\n"); printf("Press any key to exit!\\n"); getch(); exit(0); printf("Please input the key:"); scanf("%d",&n);/*输入解密密码(可以为加密时候的密码)*/ n=26-n; printf("Please input the outfile:"); scanf("%s",outfile);/*输入解密后文件的文件名*/ if((out=fopen(outfile,"w"))==NULL) printf("Can not open the outfile!\\n"); printf("Press any key to exit!\\n"); fclose(in); getch(); exit(0); while(!feof(in)) fputc(encrypt(fgetc(in),n),out); printf("\\nDecrypt is over!\\n"); fclose(in); fclose(out); sleep(1); if(ch0==\'3\') clrscr(); printf("\\nPlease input the infile:"); scanf("%s",infile);/*输入需要解密的文件名*/ if((in=fopen(infile,"r"))==NULL) printf("Can not open the infile!\\n"); printf("Press any key to exit!\\n"); getch(); exit(0); printf("Please input the outfile:"); scanf("%s",outfile);/*输入解密后文件的文件名*/ if((out=fopen(outfile,"w"))==NULL) printf("Can not open the outfile!\\n"); printf("Press any key to exit!\\n"); fclose(in); getch(); exit(0); for(i=1;i<=25;i++)/*暴力破解过程,在察看信息正确后,可以按\'Q\'或者\'q\'退出*/ rewind(in); rewind(out); clrscr(); printf("==========================================================\\n"); printf("The outfile is:\\n"); printf("==========================================================\\n"); while(!feof(in)) ch1=encrypt(fgetc(in),26-i); putch(ch1); fputc(ch1,out); printf("\\n========================================================\\n"); printf("The current key is: %d \\n",i);/*显示当前破解所用密码*/ printf("Press \'Q\' to quit and other key to continue。

\\n"); printf("==========================================================\\n"); ch1=getch(); if(ch1==\'q\'||ch1==\'Q\')/*按\'Q\'或者\'q\'时退出*/ clrscr(); printf("\\nGood Bye!\\n"); fclose(in); fclose(out); sleep(3); exit(0); printf("\\nForce decrypt is over!\\n"); fclose(in); fclose(out); sleep(1); menu(); ch0=getch(); clrscr(); printf("\\nGood Bye!\\n"); sleep(3); 。

4. 怎样编写程序:实现恺撒密码加密单词"julus"

用下面程序:新建个txt,放进去任意单词,设置#define N 5中的值,实现字母移位,达到加密目的。

本程序提供解密功能/************************************************************************//* 版权所有:信息工程学院 王明 使用时请注明出处!! *//* 算法:凯撒密码体制 e799bee5baa6e4b893e5b19e31333264643062 *//************************************************************************/#include #define N 5void jiami(char namea[256]) FILE *fp_jiami,*fp_file2; char c; fp_jiami=fopen(namea,"rb"); fp_file2=fopen("file2.txt","wb"); while(EOF!=(fscanf(fp_jiami,"%c",&c))) if((c>=\'A\'&&c=\'a\'&&c=\'A\'&&c=\'a\'&&c=\'a\'&&c=\'A\'&&c=\'a\'&&c=\'A\'&&c=\'a\'&&c=\'A\'&&c<=\'Z\')c=c+32; fprintf(fp_file3,"%c",c); fclose(fp_file3); fclose(fp_jiemi); int main() char name[256]; int n; printf("输入你要操作的TXT文本:"); gets(name); printf("\\n请选择需要进行的操作:\\n"); printf(" 1:加密 2:解密 \\n"); printf("输入你的选择:"); scanf("%d",&n); switch(n) case 1:jiami(name);printf("\\t加密成功!!\\n\\n"); break; case 2:jiemi(name);printf("\\t解密成功!!\\n\\n"); break; default:printf("输入操作不存在!"); return 0;。

5. 谁有PYTHON编写的凯撒密码的加密和解密代码

给你写了一个.

def convert(c, key, start = \'a\', n = 26):

a = ord(start)

offset = ((ord(c) - a + key)%n)

return chr(a + offset)

def caesarEncode(s, key):

o = ""

for c in s:

if c.islower():

o+= convert(c, key, \'a\')

elif c.isupper():

o+= convert(c, key, \'A\')

else:

o+= c

return o

def caesarDecode(s, key):

return caesarEncode(s, -key)

if __name__ == \'__main__\':

key = 3

s = \'Hello world!\'

e = caesarEncode(s, key)

d = caesarDecode(e, key)

print e

print d

运行结果:

Khoor zruog!

Hello world!

以上是关于用jQuery.md5.js加密密码后后台怎么解密?的主要内容,如果未能解决你的问题,请参考以下文章

access数据库里面的用户名用MD5加密怎么样来解密?

SQL数据库里面后台的密码加密了密文是:128xwM4bvLVmvhz4zEtMlw== 请问如何解密。怎样查看是怎样加密的?

手机信息加密有不知道密码,该怎么解密?

RSA加密

RSA加密

asp使用MD5加密的密码登录怎么解决?