Classic ASP Requires Chilkat v11.0.0+
Classic ASP
Get EC Public Key from EC Private Key
See more ECC Examples
Demonstrates how to get an EC public key from an EC private key.Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' We have an ECC private key...
' The contents of the private key PEM file look like this:
' -----BEGIN PRIVATE KEY-----
' MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg3J8q/24D1sEKGdP9
' 72MGYElLGpw/a56Y3t6pfON3uhShRANCAATlSmoizyhAwoYZAOuFBATl07/1RR54
' a1Dzfm16grxJe666AGKR+bSs24hk7TEpaeCTvT8YOOM3l+xKFg7zq6Q9
' -----END PRIVATE KEY-----
set privKey = Server.CreateObject("Chilkat.PrivateKey")
success = privKey.LoadPemFile("qa_data/ecc/secp256r1-key-pkcs8.pem")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( privKey.LastErrorText) & "</pre>"
Response.End
End If
' Get the public key.
set pubKey = Server.CreateObject("Chilkat.PublicKey")
success = privKey.ToPublicKey(pubKey)
' Save the public key to a PEM file.
success = pubKey.SavePemFile(0,"qa_data/ecc/secp256r1-pubkey.pem")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pubKey.LastErrorText) & "</pre>"
Response.End
End If
' The contents of the ECC public key PEM file look like this:
' -----BEGIN PUBLIC KEY-----
' MIIBSzCCAQMGByqGSM49AgEwgfcCAQEwLAYHKoZIzj0BAQIhAP////8AAAABAAAA
' AAAAAAAAAAAA////////////////MFsEIP////8AAAABAAAAAAAAAAAAAAAA////
' ///////////8BCBaxjXYqjqT57PrvVV2mIa8ZR0GsMxTsPY7zjw+J9JgSwMVAMSd
' NgiG5wSTamZ44ROdJreBn36QBEEEaxfR8uEsQkf4vOblY6RA8ncDfYEt6zOg9KE5
' RdiYwpZP40Li/hp/m47n60p8D54WK84zV2sxXs7LtkBoN79R9QIhAP////8AAAAA
' //////////+85vqtpxeehPO5ysL8YyVRAgEBA0IABOVKaiLPKEDChhkA64UEBOXT
' v/VFHnhrUPN+bXqCvEl7rroAYpH5tKzbiGTtMSlp4JO9Pxg44zeX7EoWDvOrpD0=
' -----END PUBLIC KEY-----
Response.Write "<pre>" & Server.HTMLEncode( "Success.") & "</pre>"
%>
</body>
</html>