-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencode.c
39 lines (34 loc) · 808 Bytes
/
encode.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* (c) Yves Lafon <[email protected]> */
/* */
/* $Id: encode.c,v 1.2 2007/07/03 14:02:58 ylafon Exp $ */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "encode.h"
void Rot13(encoded)
char *encoded;
{
char *tmp;
for (tmp = encoded; *tmp && *tmp!='\n'; tmp++) {
if (*tmp>='a' && *tmp<'n')
*tmp += 13;
else if (*tmp>'m' && *tmp<='z')
*tmp -= 13;
else if (*tmp>='A' && *tmp<'N')
*tmp += 13;
else if (*tmp>'M' && *tmp<='Z')
*tmp -= 13;
}
}
void Decode(encoded)
char *encoded;
{
char *tmp1, *tmp2;
for (tmp1 = tmp2 = encoded; *tmp1 && *tmp1!='\n'; tmp1++) {
*tmp2 = (*tmp1++ - 0x41) << 4;
if (*tmp1 && *tmp1!='\n')
*tmp2++ |= *tmp1 - 0x41;
}
if (tmp1 != tmp2)
*tmp2 = 0;
}