(Classic ASP) Get Base64 Public Key from Private Key
Demonstrates how to get the public key in base64 format from a private key. 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
' Load a private key from base64.
set bd = Server.CreateObject("Chilkat.BinData")
success = bd.AppendEncoded("MHQCA....n0Q==","base64")
set privKey = Server.CreateObject("Chilkat.PrivateKey")
success = privKey.LoadAnyFormat(bd,"")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( privKey.LastErrorText) & "</pre>"
Response.End
End If
set pubKey = Server.CreateObject("Chilkat.PublicKey")
success = privKey.ToPublicKey(pubKey)
pubKeyBase64 = pubKey.GetEncoded(1,"base64")
Response.Write "<pre>" & Server.HTMLEncode( pubKeyBase64) & "</pre>"
%>
</body>
</html>
|