首页 > 编程 > ASP > 正文

在asp中通过vbs类实现rsa加密与解密,建议入精华

2024-05-04 11:06:17
字体:
来源:转载
供稿:网友
在asp中通过vbs类实现rsa加密与解密,建议入精华

本文章有两文件组成
test.asp 测试演示文件
clsrsa.asp 实现rsa加密与解密的vbs类文件
下面是代码:

1. test.asp

<%
rem 文章标题:在asp中通过vbs类实现rsa加密与解密
rem 收集整理:yanek
rem 联系:[email protected]

%>
<%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>
        <h1>rsa cipher demonstration</h1>
        <p>
            you will first 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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表