Created
April 10, 2015 16:10
-
-
Save nuit/4402d4e0171d4f3e5c46 to your computer and use it in GitHub Desktop.
vernam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(){ | |
int M,m; | |
int ch,k,r; | |
ch=getchar(); | |
//ascii >> A=65,a=97 e Z=90,z=122 | |
for (M=65, m=97;(M<=90) && (m<=122);M++, m++){ | |
while ((ch=getchar()) != EOF){ | |
r=rand()%26; | |
if ((ch>='A') && (ch<='Z')){ | |
k=ch+r; | |
putchar((ch-'A'+k)%26+'A'); | |
} | |
else if ((ch>='a') && (ch<='z')){ | |
k=ch+r; | |
putchar((ch-'a'+k)%26+'a'); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment