Write a program in C++, C# or Java to implement RSA algorithm using Libraries (API).

SHA1Cryptographic hash functions are widely used for securing communication, storing hash values of passwords in databases, verifying that a message or a file has been transmitted correctly between two entities and others. One of the most widely used algorithms is MD5 (Message Digest Five), which produces a 128-bit hash value, usually expressed as a 32 hex digits number. It is the successor of MD4 and MD2, all of them being developed by Ronald Rivest. Another hash algorithm, also based on MD4, is SHA-1, a cryptographically secure one-way hash algorithm that produces a 160-bit message digest (usually represented as a 40 hex digit number).
Point to be remember before executing the Program
  • Create Text File (.txt) for Message. Eg.: (""H:\\workspace\\ICS\\src\\messageDigest.txt"")
  • Create the Java Class of name : SHA1
import java.io.*;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/*
 * author @ Professional Cipher [www.professionalcipher.com] 
 */

public class SHA1 {

 public SHA1(){
  
 }
 
 public static void main(String args[]) throws NoSuchAlgorithmException, FileNotFoundException , IOException{
  
  MessageDigest messageDigest = MessageDigest.getInstance("MD5");
  FileInputStream fileInputStream = new FileInputStream("H:\\workspace\\ICS\\src\\messageDigest.txt");
  
  byte[] bytes = new byte[30];
  int i=0;
  while((i=fileInputStream.read(bytes))!=-1)
  {
   messageDigest.update(bytes , 0 , i);
  }
  
  fileInputStream.close();
  byte[] digest = messageDigest.digest();
  
  FileOutputStream fileOutputStream = new FileOutputStream("H:\\workspace\\ICS\\src\\digest.txt");
  fileOutputStream.write(digest);
  fileOutputStream.close();
  
 }
 
}
For All BE IT Programs : Click Here