JDK Tutorials - Herong's Tutorial Examples - v6.32, by Herong Yang
RSA Private Key and Public Key Pair Sample
This section provides a tutorial example on how to run JcaKeyPair.java to generate a RSA private key and public key pair sample. Keys are stored PKCS#8 and X.509 encoding formats.
Now let's see the private key and public key generated by the RSA algorithm:
herong> java JcaKeyPair 512 rsa rsa KeyPairGenerator Object Info: Algorithm = rsa Provider = SunRsaSign version 10 Key Size = 512 toString = java.security.KeyPairGenerator$Delegate@880ec60 Private Key Info: Algorithm = RSA Saved File = rsa.pri Size = 344 Format = PKCS#8 toString = sun.security.rsa.RSAPrivateCrtKeyImpl@fffe44c2 Public Key Info: Algorithm = RSA Saved File = rsa.pub Size = 94 Format = X.509 toString = Sun RSA public key, 512 bits modulus: 8501360768135846209281243379820297263815731275954336277423435334 0634158627863282350694681262665444471208937440958312181724505235 80919843567632096247396963 public exponent: 65537 herong> java -cp . HexWriter rsa.pri rsa_pri.hex herong> more rsa_pri.hex 30820154020100300D06092A864886F7 0D01010105000482013E3082013A0201 00024100A251C92CCA3E7B6599146DDB 10044807B3AA1EFA8BE6274D329765E0 CC5A0EA03CA8F010524A892484A7C964 98660A20DBD3AA3E92D2CB5037DD95B7 F69BBA630203010001024040603F714C 24CBBBD7A28A8F3F22F38E5A6B362E18 1E07A84E504D4F82BC94DFC402775FF0 7428E97620750BF965E5E960B5B6FFEB 64A62813B8AAFF1A6B5101022100F2D0 13B5A010AAE6C77D3993F7A5C1ED7DB4 F2BECC8383E6943620628B8680910221 00AB2293FF88A958F22F7A087BA00605 64135A9A4A4014538013B0ED1A1CBD05 B3022100D50474F61739E824D48868B6 064216331AE05F41C23BF2C09BF02C53 27E2D4F1022051C44EB44C46A5B1E98F 441855482B313AB212802187D4B1A036 EBC28B32A15302205D1A78497DC3E337 7224BBAF3F50791F2CEC932B04DD28AD 3763F6E233DBA634 herong> java -cp . HexWriter rsa.pub rsa_pub.hex herong> more rsa_pub.hex 305C300D06092A864886F70D01010105 00034B003048024100A251C92CCA3E7B 6599146DDB10044807B3AA1EFA8BE627 4D329765E0CC5A0EA03CA8F010524A89 2484A7C96498660A20DBD3AA3E92D2CB 5037DD95B7F69BBA630203010001
Table of Contents
Date, Time and Calendar Classes
Date and Time Object and String Conversion
Number Object and Numeric String Conversion
Locales, Localization Methods and Resource Bundles
Calling and Importing Classes Defined in Unnamed Packages
HashSet, Vector, HashMap and Collection Classes
Character Set Encoding Classes and Methods
Encoding Conversion Programs for Encoded Text Files
Datagram Network Communication
DOM (Document Object Model) - API for XML Files
DTD (Document Type Definition) - XML Validation
XSD (XML Schema Definition) - XML Validation
XSL (Extensible Stylesheet Language)
Message Digest Algorithm Implementations in JDK
►Private key and Public Key Pair Generation
Private and Public Keys and Related Interfaces
KeyPair and KeyPairGenerator Classes
Key Pair Sample Program - JcaKeyPair.java
DSA Private Key and Public Key Pair Sample
►RSA Private Key and Public Key Pair Sample
DiffieHellman Private Key and Public Key Pair Sample
PKCS#8/X.509 Private/Public Encoding Standards
Digital Signature Algorithm and Sample Program
"keytool" Commands and "keystore" Files
KeyStore and Certificate Classes
Secret Key Generation and Management
Cipher - Encryption and Decryption
The SSL (Secure Socket Layer) Protocol
SSL Socket Communication Testing Programs