/* vcc/crypt.c
*
* This file is part of vcc.
*
* vcc is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* vcc is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with vcc. If not, see
*/
#include
#include
#include
#include
#include
#include
#include
#define KEYSIZE 8
#define BLKSIZE 8
int keysize, blksize;
int msgsize;
__uint64_t key;
int show_algo_info(void) {
keysize = KEYSIZE;
blksize = BLKSIZE;
printf("key size: %d\n", keysize);
printf("block size: %d\n", blksize);
printf("maximum message size: %ld\n", MSG_SIZE);
return 0;
}
int crypt_init(void *k) {
key = *(__uint64_t *) &k;
return 0;
}
char *encrypt(char *msg) {
int i;
for (i = 0; msg[i]; i++) {
if (msg[i] == 'z')
msg[i] = 'a';
else if (msg[i] == 'Z')
msg[i] = 'A';
msg[i]++;
}
return msg;
}
int decrypt(char *msg) {
int i;
for (i = 0; msg[i]; i++) {
if (msg[i] == 'a')
msg[i] = 'z';
else if (msg[i] == 'A')
msg[i] = 'Z';
else
msg[i]--;
}
return 0;
}