在asp中通过vbs类实现rsa加密与解密的代码

2019-01-13 22:20:49王旭
    


clsrsa.asp  


<% 
rem 实现rsa加密与解密的vbs类文件 
rem 文章标题:在asp中通过vbs类实现rsa加密与解密 
rem 收集整理:yanek 
rem 联系:aspboy@263.net 

' RSA Encryption Class 

' .PrivateKey 
'        Your personal private key.  Keep this hidden. 

' .PublicKey 
'        Key for others to encrypt data with. 

' .Modulus 
'        Used with both public and private keys when encrypting 
'        and decrypting data. 

' .GenKey() 
'        Creates Public/Private key set and Modulus 

' .Crypt(pLngMessage, pLngKey)   
'        Encrypts/Decrypts message and returns  
'        as a string. 

' .Encode(pStrMessage) 
'        Encrypts message and returns in double-hex format 

' .Decode(pStrMessage) 
'        Decrypts message from double-hex format and returns a string 

Class clsRSA 

    Public PrivateKey 
    Public PublicKey 
    Public Modulus 

    Public Sub GenKey() 
        Dim lLngPhi 
        Dim q 
        Dim p 

        Randomize 

        Do 
            Do 

                ' 2 random primary numbers (0 to 1000) 
                Do 
                    p = Rnd * 1000  1 
                Loop While Not IsPrime(p)