Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
639 B
1
Indexable
Never
void CSR_encrypt(char msg[])
{
 char enc[25];
 int key, i, j, k;
 printf("key: ");
 scanf("%i", &key);
 for(i=0; i<strlen(msg); i++)
 for(j=0; j<strlen(letters); j++)
 if(msg[i]==letters[j]) {
 if((j+key)<strlen(letters))
 enc[i]=letters[j+key];
 else {
 k=(j+key)-strlen(letters);
 enc[i]=letters[k];
 }
 }
 printf("enc: ");
 for(i=0; i<strlen(msg); i++)
 printf("%c", enc[i]);
 printf("\n");
}
void CSR_enc_math(char msg[])
{
// copy from above
 for(i=0; i<strlen(msg); i++)
 for(j=0; j<strlen(letters); j++)
 if(msg[i]==letters[j]) {
 k=(j+key)%strlen(letters);
 enc[i]=letters[k];
 }
// copy from above
}