IMPLEMENTATION OF SHA-1 ALGORITHM using JAVA

Image
AIM: To   write a java program to calculate the message digest of a text using the SHA-1 algorithm ALGORITHM: Step 1: Input the plain text Step 2: Append padding bits Step 3: Append length Step 4:Initialize   buffer. Step 5: Process message in 512-bit (16word)blocks Step 6: Encrypted in hexa decimal format Step 7: Display the encrypted text. PROGRAM: importjava.security.*; public class SHA1 { public static void main(String[] a) { try { MessageDigest md = MessageDigest.getInstance("SHA1"); System.out.println("Message digest object info: "); System.out.println(" Algorithm = " +md.getAlgorithm()); System.out.println(" Provider = " +md.getProvider()); System.out.println(" ToString = " +md.toString());   String input = ""; md.update(input.getBytes()); byte[] output = md.digest(); System.out.println(); System.out.println("SHA1(\""+...

IMPLEMENTATION OF RAIL FENCE


AIM:



            To write a  C++ program  to Implement Rail fence row & column transformation.



ALGORITHM:

Step 1:  Enter the plain text for encryption.

Step 2:  Enter the depth in integer (number of rows)

Step 3: In the rail fence cipher, the plaintext is written downwards and diagonally on successive "rails" of an imaginary fence, then moving up when we reach the bottom rail.

Step 4: When we reach the top rail, the message is written downwards again until the whole plaintext is written out.

Step 5: The message is then read off in rows. Thus, the cipher text is generated.





PROGRAM:

#include<iostream>

using namespace std;

int main()

{

inti,j=0,d,k=0;

char p[50],ct[50][50];

cout<<"Enter the plain text:\n";

cin>>p;

cout<<"\nEnter the depth in the integer:";

cin>>d;

            //declare null for empty array values

for(i=0;i<50;i++)

            {

for(j=0;j<50;j++)

                       {

ct[i][j]='\0';

                        }

            }

            k=0;

       //loop up to string lenght of the plaintext

            {

for(i=0;i<strlen(p);i++)

            {

for(j=0;j<d;j++)

                        {

                                    if(k<=strlen(p))

ct[i][j]=p[k];



                                    k++;

                        }

ct[i][j]='\0';

                        }

            }

for(i=0;i<d;i++)

            {

            for(j=0;j<strlen(p);j++)

                        {

if(ct[j][i]!='\0')

                                       {

printf("%c",ct[j][i]);

                                       }

                        }

cout<<"\n";

            }

            // Read the text

cout<<"\nThe encrypted text is:\n";

for(i=0;i<d;i++)

            {

for(j=0;j<strlen(p);j++)

                        {

if(ct[j][i]!='\0')

cout<<ct[j][i];

                      }

            }

            return 0;

}

OUTPUT:

Comments

Popular posts from this blog

IMPLEMENTATION OF SHA-1 ALGORITHM using JAVA

IMPLEMENTATION OF RSA ALGORITHM using c++

IMPLEMENTATION OF DIFFIE HELLMAN KEY EXCHANGE ALGORITHM