Caesar Crypted With C Programming Language

Caesar Crypted With C Language

Caesar Crypted


#include <stdio.h>
void encrypted(char arr[],int arrL,int shifted);
void decrypted(char arr[],int arrL,int shifted);
char tArr[]={};

int main() {
    char arr[]={'F','R','I','N','G','E'};
    int shifted=3;//number of steps
    int arrL=(int)sizeof(arr);//array length
    encrypted(arr,arrL,shifted);
    printf("\t  Caesar Crypted\n");    
    printf("\tEncrypted : %s\n",tArr);
    decrypted(tArr,arrL,shifted);
    printf("\t------------------\n\tDecrypted : %s",tArr);
 return 0;
}

void encrypted(char arr[],int arrL,int shifted){
    for(int i=0 ; i <arrL; i++){
        int j=(int)arr[i];
        j +=shifted;
        tArr[i]=(char)j;
    }
}
void decrypted(char arr[],int arrL,int shifted){
      for(int i=0 ; i <arrL; i++){
        int j=(int)arr[i];
        j -=shifted;
        tArr[i]=(char)j;
    }
}

Comments

Popular posts from this blog

Tech Duos For Web Development

CIFAR-10 Dataset Classification Using Convolutional Neural Networks (CNNs) With PyTorch

Long-short-term-memory (LSTM) Word Prediction With PyTorch