| 域名空间 下载中心 社区论坛 信息公告 my小屋 |
![]() |
联系我们 设为首页 加入收藏 |
|
首页 | 新闻资讯 | 编程开发 | 网页设计 | 图形图象 | 网络媒体 | 网站模板 | 数 据 库 | 投稿 论坛 | 操作系统 | 系统优化 | 网络安全 | 黑客技术 | 硬件学堂 | 硬件报价 | 服 务 器 | 地图 专题 | 应用软件 | 聊天通讯 | q q 专栏 | 建站经验 | 在线工具 | 站长club | 注 册 表 | 旧版 社会 | 游戏娱乐 | 设计欣赏 | 疑难解答 | 社区论坛 | 网络赚钱 | 网站地图 | 广告服务 | 服务 |
| 新版上线![旧版] | |||||
注:打开慢时请稍等
|
rsa.asp <% rem 在asp中实现加密与解密,加密方法:根据rsa rem 联系:hnsoso@sina.com class clsrsa public privatekey public publickey public modulus public function crypt(plngmessage, plngkey) on error resume next dim llngmod dim llngresult dim llngindex if plngkey mod 2 = 0 then llngresult = 1 for llngindex = 1 to plngkey / 2 llngmod = (plngmessage ^ 2) mod modulus ' mod may error on key generation llngresult = (llngmod * llngresult) mod modulus if err then exit function next else llngresult = plngmessage for llngindex = 1 to plngkey / 2 llngmod = (plngmessage ^ 2) mod modulus on error resume next ' mod may error on key generation llngresult = (llngmod * llngresult) mod modulus if err then exit function next end if crypt = llngresult end function public function encode(byval pstrmessage) dim llngindex dim llngmaxindex dim lbytascii dim llngencrypted llngmaxindex = len(pstrmessage) if llngmaxindex = 0 then exit function for llngindex = 1 to llngmaxindex lbytascii = asc(mid(pstrmessage, llngindex, 1)) llngencrypted = crypt(lbytascii, publickey) encode = encode & numbertohex(llngencrypted, 4) next end function public function decode(byval pstrmessage) dim lbytascii dim llngindex dim llngmaxindex dim llngencrypteddata decode = "" llngmaxindex = len(pstrmessage) for llngindex = 1 to llngmaxindex step 4 llngencrypteddata = hextonumber(mid(pstrmessage, llngindex, 4)) lbytascii = crypt(llngencrypteddata, privatekey) decode = decode & chr(lbytascii) next end function private function numbertohex(byref plngnumber, byref plnglength) numbertohex = right(string(plnglength, "0") & hex(plngnumber), plnglength) end function private function hextonumber(byref pstrhex) hextonumber = clng("&h" & pstrhex) end function end class %> test.asp <!--#include file="rsa.asp"--> <% function encryptstr(message) dim lngkeye dim lngkeyd dim lngkeyn dim strmessage dim objrsa lngkeye = "32823" lngkeyd = "20643" lngkeyn = "29893" strmessage = message set objrsa = new clsrsa objrsa.publickey = lngkeye objrsa.modulus = lngkeyn encryptstr = objrsa.encode(strmessage) set objrsa = nothing end function function decryptstr(message) dim lngkeye dim lngkeyd dim lngkeyn dim strmessage dim objrsa lngkeye = "32823" lngkeyd = "20643" lngkeyn = "29893" strmessage = message set objrsa = new clsrsa objrsa.privatekey =lngkeyd objrsa.modulus=lngkeyn decryptstr=objrsa.decode(strmessage) set objrsa = nothing end function dim last,first first="sohu" response.write "加密前为:"&first last=encryptstr(first) response.write "加密后为"&last response.write "解密后为" &decryptstr(last) %> 编辑: [发送给好友] [打印本页] [关闭窗口] [返回顶部] 上一篇:随机生成文件名的函数 下一篇:asp自动解压rar文件 转载请注明来源:www.iyit.net 特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。 |
| 最新更新 | 热点排行 | 推荐新闻 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 友情链接 | ||||||
| 设置首 页 - 版权声明 - 广告服务 - 关于我们 - 联系我们 - 友情连接 |
| |||||||