|
NOTA: La traducción de esta documentación es un esfuerzo personal y voluntario, no es un documento oficial de Sun Microsystems
ni Oracle ni está patrocinado por ninguna de estas empresas. Los documentos originales (en inglés) están disponibles en:
http://java.sun.com/docs/books/tutorial/.
Dirija cualquier comentario, petición, felicitación, etc. a tutorialesjava_@RROBA_codexion.com. |
Si desea ayudar a mantener en funcionamiento esta web, colaborar con la traducción de estos documentos o necesita que se traduzca algĂșn capĂtulo en concreto puede realizar una donación directa mediante Paypal:
|
TheGenSigprogram you are about to create will use the JDK Security API to generate keys and a digital signature for data using the private key and to export the public key and the signature to files. The application gets the data file name from the command line.The following steps create the
GenSigsample program.
- Prepare Initial Program Structure
Create a text file named
GenSig.java. Type in the initial program structure (import statements, class name,mainmethod, and so on).
- Generate Public and Private Keys
Generate a key pair (public key and private key). The private key is needed for signing the data. The public key will be used by the
VerSigprogram for verifying the signature.
- Sign the Data
Get a
Signatureobject and initialize it for signing. Supply it with the data to be signed, and generate the signature.
- Save the Signature and the Public Key in Files
Save the signature bytes in one file and the public key bytes in another.
- Compile and Run the Program