Ruby
Ruby
DSA Public Key PEM to DER Conversion
See more DSA Examples
Converts a DSA public key from PEM format to DER.Chilkat Ruby Downloads
require 'chilkat'
success = false
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
dsa = Chilkat::CkDsa.new()
# Load a PEM public key.
pemPublicKey = dsa.loadText("dsa_pub.pem")
# Import the public key PEM into the DSA object.
success = dsa.FromPublicPem(pemPublicKey)
if (success != true)
print dsa.lastErrorText() + "\n";
exit
end
# Write it out as a DER file:
success = dsa.ToPublicDerFile("dsa_pub.der")
if (success != true)
print dsa.lastErrorText() + "\n";
exit
end
print "Finished!" + "\n";