Encrypt and decrypt the corresponding function in ASP

Source: Internet
Author: User
In the ASP encryption method has the corresponding decryption method is not much, and now according to the predecessor data in the ASP encryption and decryption function
Rsa.asp
<%
REM Encryption and decryption in ASP, encryption method: according to RSA
REM Contact: 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.