Skip to content

Instantly share code, notes, and snippets.

@6uclz1
Last active November 16, 2015 06:47
Show Gist options
  • Save 6uclz1/b5c476ccbc5b4de90d16 to your computer and use it in GitHub Desktop.
Save 6uclz1/b5c476ccbc5b4de90d16 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
void encrypt(char*, int);
int main()
{
int key;
char message[20];
printf("? ");
scanf("%s", message);
printf("key? ");
scanf("%d", &key);
printf("%s\n", message);
encrypt(message, key);
printf("%s\n", message);
}
void encrypt(char *s, int key)
{
int i;
for(i = 0; *s != '\0'; i++) {
*s = *s + (i % key + 1);
s++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment