Encryption | decryption | Essence in ASP through the VBS class to achieve RSA encryption and decryption, recommended into the essence
This article consists of two documents
Test.asp Test Demo file
Clsrsa.asp to implement RSA encryption and decryption of the VBS class file
Here's the code:
1. test.asp
<%
REM Article title: Implementing RSA Encryption and decryption via the VBS class in ASP
REM Collection and collation: Yanek
REM Contact: aspboy@263.net
%>
<%option explicit%>
<!--#INCLUDE file= "clsrsa.asp"-->
<%
Dim Lngkeye
Dim Lngkeyd
Dim Lngkeyn
Dim strmessage
Dim Objrsa
If Not Request.Form = "" Then
Lngkeye = Request.Form ("Keye")
Lngkeyd = Request.Form ("Keyd")
Lngkeyn = Request.Form ("Keyn")
strmessage = Request.Form ("message")
Set Objrsa = New Clsrsa
Select case Request.Form ("Action")
Case "Generate Keys"
Call Objrsa.genkey ()
Lngkeye = Objrsa.publickey
Lngkeyd = Objrsa.privatekey
Lngkeyn = Objrsa.modulus
Case "Encrypt"
Objrsa.publickey = Lngkeye
Objrsa.modulus = Lngkeyn
strmessage = Objrsa.encode (strmessage)
Case "Decrypt"
Objrsa.privatekey = Lngkeyd
Objrsa.modulus = Lngkeyn
strmessage = Objrsa.decode (strmessage)
End Select
Set Objrsa = Nothing
End If
%>
<HTML>
<HEAD>
<title>rsa Cipher demonstration</title>
</HEAD>
<BODY>
<P>
You'll need to generate your public/privage Key-pair
Before you can encrypt/decrypt messages.
</P>
<form method= "POST" >
<TABLE>
<TR>
<td>public key</td>
<td><input name= "Keye" value= "<%=server.htmlencode (lngkeye)%>" ></TD>
<TD rowspan= "3" >
<input type= "Submit" name= "Action" value= "Generate Keys" >
</TD>
</TR>
<TR>
<td>private key</td>
&nbs