#5, First Floor, 4th Street , Dr. Subbarayan Nagar, Kodambakkam, Chennai-600 024 pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to apply RSA algorithm asymmetric algorithm in ns2?

Description

Message from the source to destination is sent in encrypted form. Input message is encrypted using the public key of the receiver and it is decrypted at the receiver using its private key. Encryption and decryption follows the Asymmetric Cryptography (RSA) Algorithm.

Sample Code

#Filename: asymmetric_Crypto.cc

Encryption() {
len = strlen(imsg);
while(i != len)
{
pt = m[i];
k = 1;
for (j = 0;j < key;j++)
{
k = k * pt;
k = k % n;
}
ct = k + 96;
en1[i] = ct;
}
printf("\nTHE ENCRYPTED MESSAGE IS\n");
for (w = 0; w < len; w++)
{
printf("%c", en1[w]);
}
}

Decryption () {
while (i != mdelen)
{
count2++;
ct = temp[i];
k = 1;
for (j = 0;j < key;j++)
{
k = k *ct;
k = k % n;
}
h[i] = pt;
i++;
}
printf("\nTHE DECRYPTED MESSAGE IS\n");
for (v = 0; v < mdelen; v++)
{
printf("%c", h[v]);
}
mdecr = h;
}
}

 


Screenshots