paip.跨平台跨语言自定义加密方法
今天主要是要在asp和php系统模块间进行参数传递,为了方便,不用md5签名,直接准备使用
des加密。。可是asp和php的des不能相互加觖密。。。好向还有什么cbc模式,iv向量什么的
。一大堆,调了半天还是不行,算了,还是自己写加密方法吧。。
密码加密主要的方法就是替换,移位。。另外,我的要求是,还需要可以使用密钥,此外还需要算法
简单。。des算法一看就是一大陀,md,难用。pass。。。虽然效果好,有点复杂,不好重写啊
。。
这里,我构思了下加密觖密的思路:
1.先把字符串进行反转
2.把字符串与key组进行循环相加
3.相加的结果转为16进制字符连起来。。主要是为了省点空间。。
4.返回结果就可 以了。。。
5.解密的过程反过来就可以了。。
dim key_l71723
key_l71723=iluvnjyn
dim msg
msg=admin
dim newstr
newstr=atiencode(msg,key_l71723)
response.write( newstr) '显示加密结果是d7d5e2dacf
response.write( atidecode(newstr,key_l71723) )
---------------------------------------------
function atiencode(msg,key)
msg=back_str(msg) '反转字符串
dim key_l71723
key_l71723= key
key_l71723=key_l71723+key_l71723
key_l71723=key_l71723+key_l71723
key_l71723=key_l71723+key_l71723
dim msgarr
msgarr=str2array(msg)
dim keyarr
keyarr=str2array(key_l71723)
dim newstr
newstr=
'与key组进行循环相加
for i=0 to ubound(msgarr)
dim char
char=msgarr(i)
dim newchar 'int format
newchar = asc (char)+asc(keyarr(i))
newchar= hex(newchar)
newstr=newstr+cstr(newchar)
next
atiencode=newstr
end function
function atidecode(msg,key)
dim key_l71723
key_l71723= key
key_l71723=key_l71723+key_l71723
key_l71723=key_l71723+key_l71723
key_l71723=key_l71723+key_l71723
dim msgarr
msgarr=str2arrayx(msg,2)
dim keyarr
keyarr=str2array(key_l71723)
dim newstr
newstr=
for i=0 to ubound(msgarr)
dim charint
charint=chn10(msgarr(i) ) 'encode char
dim newchar www.2cto.com
newchar=chr( charint-ascw(keyarr(i)))
newstr=newstr+newchar
next
newstr=back_str(newstr)
atidecode=newstr
end function
作者:attilax
http://www.bkjia.com/phpjc/478092.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/478092.htmltecharticlepaip.跨平台跨语言自定义加密方法 今天主要是要在asp和php系统模块间进行参数传递,为了方便,不用md5签名,直接准备使用 des加密。。可是...