Previous | Next | Trail Map | Security in JDK 1.2  | Generating and Verifying Signatures [API]

Generating a Digital Signature

The GenSig program you are about to create will use the JDK Security API to generate keys, generate a digital signature for data using the private key, and export the public key and the signature to files. The application gets the data file name from the command line.

The steps to create the GenSig sample program are the following:

  1. Prepare Initial Program Structure

    Create a text file named GenSig.java. Type in the initial program structure (import statements, class name, main method, and so on).

  2. 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 VerSig program for verifying the signature.

  3. Sign the Data

    Get a Signature object and initialize it for signing. Supply it the data to be signed, and generate the signature.

  4. Save the Signature and the Public Key in Files

    Save the signature bytes in one file, and the public key bytes in another.

  5. Compile the Program

    Use javac to compile the Java program created in the previous steps.

  6. Run the Program

    And finally, use java, the interpreter, to run the program.


Previous | Next | Trail Map | Security in JDK 1.2  | Generating and Verifying Signatures [API]