How to Apply Symmetric Cryptography in NS2

Description

Message from the source to destination is sent in encrypted form. Input message is encrypted using the symmetric key and it is decrypted at the receiver using the same key. Encryption and decryption follows the symmetric cryptography algorithm.

#Filename: symmetric_Crypto.cc

Encryption() {

int key =brokey;
int i=0;
for (i=0;i<strlen(out);i++)
{
out[i]=(out[i]+key)%128;
}

Decryption () {
int key =brokey;
int i=0;
for (i=0;i<strlen(out);i++)
{
out[i]=(out[i]-key)%128;
}

data=out;