(Classic ASP) Use Base64 RSA Key to Encrypt
Loads a Base64 RSA key and uses it to encrypt a string, returning the result in base64. Note: This example requires Chilkat v11.0.0 or greater.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
set pubkey = Server.CreateObject("Chilkat.PublicKey")
success = pubkey.LoadBase64("MIICdgIBADA ... A9PXLk+j5A==")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pubkey.LastErrorText) & "</pre>"
Response.End
End If
set rsa = Server.CreateObject("Chilkat.Rsa")
success = rsa.UsePublicKey(pubkey)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( rsa.LastErrorText) & "</pre>"
Response.End
End If
rsa.EncodingMode = "base64"
encryptedStr = rsa.EncryptStringENC("12345678",0)
Response.Write "<pre>" & Server.HTMLEncode( encryptedStr) & "</pre>"
%>
</body>
</html>
|