script to encrypt texts

Asked

Viewed 128 times

0

I’ve been trying to create a program in c to encrypt a text, but I’m still learning many commands in c.

So far I have created a string "char text[200]" to save my text. Then I created two .txt. files one with the letters in order and the other the way I want to encrypt.

ex: arq1 "a b c d e f g h i j k l m n o p q r s t u v w x y z"

arq2 "z y x w v u t s r q p o n m l k j i h g f e d c b a"

So where 'a' turns 'z', 'b' turns 'y', etc..

I imagined that I could compare each letter of the text with the letter of arq1 and then say q equals arq2.

ex: c = arq1[2], then it checks in arq2[2] and says q 'c' will receive 'x'

my difficulty is to compare these files because I started to see now the basics of fopen and fclose.

I imagine I can do that +- like this:

#include<stdio.h>

int main(){

char text[200];
int i;
int j=0;
...
scanf("%s",text);

 for(i=0;i<(int)text;i++)
 {
 While(text[i]=!arq1[j])
  {
   j++; 
  }
  if(text[i]==arq1[j])
  {
   text[i]=arq2[j];
  }
}

return 0;
}
  • And what exactly is your doubt? Another thing, this is not an encryption, this is a substitution only. Even very easy to unravel.

  • my doubt would be how to identify each letter of my text and replace according to my table. have any specific commands ? because I’m still very "raw" in c.

  • It wouldn’t be doing all that in one file anymore?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.