Download the JDK
Search the Tutorials
Hide the TOC
Trail: Security Features in Java SE
Lesson: Generating and Verifying Signatures
Section: Verifying a Digital Signature
Generating and Verifying Signatures
Generating a Digital Signature
Prepare Initial Program Structure
Generate Public and Private Keys
Sign the Data
Save the Signature and the Public Key in Files
Compile and Run the Program
Verifying a Digital Signature
Prepare Initial Program Structure
Input and Convert the Encoded Public Key Bytes
Input the Signature Bytes
Verify the Signature
Compile and Run the Program
Weaknesses and Alternatives
Home Page > Security Features in Java SE > Generating and Verifying Signatures
« Previous • Trail • Next »
Compile and Run the Program

> `Here` is the complete source code for the `VerSig.java` program, with some comments added.

> Compile and run the program. Remember, you need to specify three arguments on the command line:

> - The name of the file containing the encoded public key bytes

> - The name of the file containing the signature bytes

> - The name of the data file (the one for which the signature was generated)
> Since you will be testing the output of the `GenSig` program, the file names you should use are
> - `suepk`

> - `sig`

> - `data`

> Here's a sample run; the bold indicates what you type.

> >     %java VerSig suepk sig data
> >     signature verifies: true

« Previous • Trail • Next »
Previous page: Verify the Signature
Next page: Weaknesses and Alternatives