Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- printf("What operation do you want to execute?\n");
- printf("Press 1 for Encryption.\n");
- printf("Press 2 for Decryption.\n");
- int i;
- scanf("%d", &i);
- if (i==1) {
- int daanebaame, kotoghor;
- printf("Forward or backward?\n");
- printf("Press 1 for Forward.\n");
- printf("Press 2 for Backward.\n");
- scanf("%d", &daanebaame);
- printf("How many positions to move?\n");
- scanf("%d", &kotoghor);
- // nicher kaj ta keno korchi bolo to?
- if (daanebaame == 2) {
- kotoghor = 26-kotoghor;
- }
- char plaintext[100];
- char cyphertext[100];
- getchar(); // eta dite hoyeche ekishathe gets ar scanf use korar karone. google korle aro jante parbe!
- gets(plaintext);
- int a,len = strlen(plaintext);
- for (a=0; a<len;a++) {
- if (plaintext[a] + kotoghor<='Z') cyphertext[a] = plaintext[a] + kotoghor;
- else cyphertext[a] = 'A' + kotoghor - ('Z'-plaintext[a]);
- }
- cyphertext[len] = '\0';
- printf("Your desired Encrypted text is:\n%s\n", cyphertext);
- }
- else if (i==2) {
- char cypher[100], plain[100];
- getchar();
- printf("Cypher text please?\n");
- gets(cypher);
- int ghor,a,len = strlen(cypher);
- for (ghor=1; ghor<=25;ghor++) {
- printf("Forwarding %d position: ", ghor);
- for (a=0; a<len; a++) {
- if (cypher[a] + ghor<='Z') plain[a] = cypher[a] + ghor;
- else plain[a] = 'A' + ghor - ('Z'- cypher[a]);
- }
- plain[len] = '\0';
- printf("%s\n", plain);
- }
- }
- else {
- printf("Vai thik moto input den na ken? :'(\n");
- printf("Abar notun kore shuru koren!\n\n");
- // nicher kaj ta interesting na? Ki hobe bolo to? :p
- main();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement