您的位置:程序门 -> vb -> 基础类



求一个vb移位字符串能加密或解密源码


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


求一个vb移位字符串能加密或解密源码[已结贴,结贴人:zhuojiangg]
发表于:2007-04-24 11:30:14 楼主
如题,如字符串是 "long123 ",要求加密为乱码,且能解密后还原字符.谢谢
发表于:2007-04-24 11:57:451楼 得分:20
'加密
private   function   encryptcode(byval   ssourcecode   as   string,   byval   iposition   as   integer)
        dim   i   as   integer
        dim   char   as   string
        dim   stargetcode   as   string
        for   i   =   1   to   len(ssourcecode)
                char   =   mid(ssourcecode,   i,   1)
                stargetcode   =   stargetcode   &   chr(asc(char)   +   iposition)
        next   i
        encryptcode   =   stargetcode
end   function
'解密
private   function   revertcode(byval   stargetcode   as   string,   byval   iposition   as   integer)
        dim   i   as   integer
        dim   char   as   string
        dim   ssourcecode   as   string
        for   i   =   1   to   len(stargetcode)
                char   =   mid(stargetcode,   i,   1)
                ssourcecode   =   ssourcecode   &   chr(asc(char)   -   iposition)
        next   i
        revertcode   =   ssourcecode
end   function
发表于:2007-04-24 11:59:072楼 得分:0
加密和解密时iposition的值必须一样
发表于:2007-04-24 15:31:133楼 得分:0
感谢!!!


快速检索

最新资讯
热门点击