首页 > 编程 > .NET > 正文

还有一个这次新写的加密类。VB.NET的。支持中文加密。总体感觉不错。

2024-07-10 13:04:18
字体:
来源:转载
供稿:网友

只有一个方法,使用的时候很简单,比如要加密就这样endecode("data",1234)
解密的时候还是这样endecode("data",1234)。很简单的。
代码:
public class encryption
    public function endecode(byval source as string, byval key as integer) as string
        dim x as single
        dim intcharnumber as integer
        dim shtradint as short
        dim strchar as string
        dim strtmp as string
        if key < 0 then
            key = key * (-1)
        end if
        x = rnd(-key)
        dim i as integer
        for i = 1 to len(source) step 1
            strchar = mid(source, i, 1)
            intcharnumber = asc(strchar)
whileencode:
            shtradint = int(127 * rnd())
            if shtradint < 30 or shtradint > 100 then goto whileencode
            intcharnumber = intcharnumber xor shtradint
            strtmp = strtmp & chr(intcharnumber)
        next i
        endecode = strtmp
        exit function
    end function
end class
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表