There seem to be not many encryption methods in ASP. Now, based on the information of the senior, the encryption and decryption functions are sorted out in Asp.
rsa.asp
<%
Rem implements encryption and decryption in ASP, encryption method: according to RSA
rem contact:[email protected]
ClassclsRSA
PublicPrivateKey
PublicPublicKey
PublicModulus
PublicFunctionCrypt(pLngMessage,pLngKey)
OnErrorResumeNext
DimlLngMod
DimlLngResult
DimlLngIndex
IfpLngKeyMod2=0Then
lLngResult=1
ForlLngIndex=1TopLngKey/2
lLngMod=(pLngMessage^2)ModModulus
'Modmayerroronkeygeneration
lLngResult=(lLngMod*lLngResult)ModModulus
IfErrThenExitFunction
Next
Else
lLngResult=pLngMessage
ForlLngIndex=1TopLngKey/2
lLngMod=(pLngMessage^2)ModModulus
OnErrorResumeNext
'Modmayerroronkeygeneration
lLngResult=(lLngMod*lLngResult)ModModulus
IfErrThenExitFunction
Next
EndIf
Crypt=lLngResult
EndFunction
PublicFunctionEncode(ByValpStrMessage)
DimlLngIndex
DimlLngMaxIndex
DimlBytAscii
DimlLngEncrypted
lLngMaxIndex=Len(pStrMessage)
IflLngMaxIndex=0ThenExitFunction
ForlLngIndex=1TolLngMaxIndex
lBytAscii=Asc(Mid(pStrMessage,lLngIndex,1))
lLngEncrypted=Crypt(lBytAscii,PublicKey)
Encode=Encode&NumberToHex(lLngEncrypted,4)
Next
EndFunction
PublicFunctionDecode(ByValpStrMessage)
DimlBytAscii
DimlLngIndex
DimlLngMaxIndex
DimlLngEncryptedData
Decode=""
lLngMaxIndex=Len(pStrMessage)
ForlLngIndex=1TolLngMaxIndexStep4