0% found this document useful (0 votes)
5 views3 pages

Digital Signature Algorithm

The document outlines the implementation of the Digital Signature Algorithm (DSA) in Java for generating and verifying digital signatures. It includes a step-by-step algorithm and a sample program that demonstrates key pair generation, signature creation, and verification. The result confirms that the digital signature is successfully generated and verified.

Uploaded by

prsundar86
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Digital Signature Algorithm

The document outlines the implementation of the Digital Signature Algorithm (DSA) in Java for generating and verifying digital signatures. It includes a step-by-step algorithm and a sample program that demonstrates key pair generation, signature creation, and verification. The result confirms that the digital signature is successfully generated and verified.

Uploaded by

prsundar86
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DIGITAL SIGNATURE ALGORITHM

EX. NO. : 3

AIM:

To implement the Digital Signature Algorithm (DSA) using Java for generating a digital
signature and verifying the authenticity and integrity of a given message.

ALGORITHM:

Step 1: Read the input message from the user.


Step 2: Generate a DSA public–private key pair using KeyPairGenerator.

Step 3: Initialize the Signature object with SHA256withDSA and the private key.

Step 4: Generate the digital signature for the input message.

Step 5: Display the generated digital signature in Base64 format.

Step 6: Initialize the Signature object with the public key for verification.

Step 7: Verify the digital signature using the original message.

Step 8: Display the verification result.


PROGRAM:
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].Base64;
import [Link];
public class DigitalSignatureDSA {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner([Link]);
[Link]("Enter the message:");
String message = [Link]();
// 1. Key Pair Generation
KeyPairGenerator keyGen = [Link]("DSA");
[Link](2048);
KeyPair keyPair = [Link]();
PrivateKey privateKey = [Link]();
PublicKey publicKey = [Link]();
// 2. Create Digital Signature
Signature signature = [Link]("SHA256withDSA");
[Link](privateKey);
[Link]([Link]());
byte[] digitalSignature = [Link]();
[Link]("Digital Signature (Base64):");
[Link]([Link]().encodeToString(digitalSignature));
// 3. Verify Digital Signature
Signature verifySig = [Link]("SHA256withDSA");
[Link](publicKey);
[Link]([Link]());
boolean isVerified = [Link](digitalSignature);
[Link]("Signature Verification Result: " + isVerified);
}
}
OUTPUT:

RESULT:

The digital signature is successfully generated and verified using the Digital Signature
Algorithm (DSA).

You might also like