Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added a new, smaller and faster algorithm! Added rot47.c - a rot47 en…

…coder
  • Loading branch information...
commit 0e93a22ebc213ac08970dae804c40691de42b196 1 parent c8060c6
aliclubb authored
5 Makefile
@@ -7,6 +7,7 @@ all:
7 7 ifeq ($(OS), Darwin)
8 8 $(CC) $(CFLAGS) -o bin/rot13 rot-tools/rot13.c
9 9 $(CC) $(CFLAGS) -o bin/rot18 rot-tools/rot18.c
  10 + $(CC) $(CFLAGS) -o bin/rot47 rot-tools/rot47.c
10 11 $(CC) $(CFLAGS) -o bin/ascii2char ascii-tools/ascii2char.c
11 12 $(CC) $(CFLAGS) -o bin/char2ascii ascii-tools/char2ascii.c
12 13 $(CC) $(CFLAGS) -o bin/ascii-tools ascii-tools/ascii-tools.c
@@ -14,6 +15,7 @@ endif
14 15 ifeq ($(OS), Linux)
15 16 $(CC) $(CFLAGS) -o bin/rot13 rot-tools/rot13.c
16 17 $(CC) $(CFLAGS) -o bin/rot18 rot-tools/rot18.c
  18 + $(CC) $(CFLAGS) -o bin/rot47 rot-tools/rot47.c
17 19 $(CC) $(CFLAGS) -o bin/ascii2char ascii-tools/ascii2char.c
18 20 $(CC) $(CFLAGS) -o bin/char2ascii ascii-tools/char2ascii.c
19 21 $(CC) $(CFLAGS) -o bin/ascii-tools ascii-tools/ascii-tools.c
@@ -21,6 +23,7 @@ endif
21 23 ifeq ($(OS), CYGWIN_NT-5.1)
22 24 $(CC) $(CFLAGS) -o bin/rot13 rot-tools/rot13.c
23 25 $(CC) $(CFLAGS) -o bin/rot18 rot-tools/rot18.c
  26 + $(CC) $(CFLAGS) -o bin/rot47 rot-tools/rot47.c
24 27 $(CC) $(CFLAGS) -o bin/ascii2char ascii-tools/ascii2char.c
25 28 $(CC) $(CFLAGS) -o bin/char2ascii ascii-tools/char2ascii.c
26 29 $(CC) $(CFLAGS) -o bin/ascii-tools ascii-tools/ascii-tools.c
@@ -28,6 +31,7 @@ endif
28 31 install:
29 32 cp bin/rot13 /usr/local/bin/rot13
30 33 cp bin/rot18 /usr/local/bin/rot18
  34 + cp bin/rot47 /usr/local/bin/rot47
31 35 cp bin/ascii2char /usr/local/bin/ascii2char
32 36 cp bin/char2ascii /usr/local/bin/char2ascii
33 37 cp bin/ascii-tools /usr/local/bin/ascii-tools
@@ -38,6 +42,7 @@ clean:
38 42 uninstall:
39 43 rm -f /usr/local/bin/rot13
40 44 rm -f /usr/local/bin/rot18
  45 + rm -f /usr/local/bin/rot47
41 46 rm -f /usr/local/bin/ascii2char
42 47 rm -f /usr/local/bin/char2ascii
43 48 rm -f /usr/local/bin/ascii-tools
2  README.md
Source Rendered
... ... @@ -1,4 +1,4 @@
1 1 misc-tools
2 2 ==========
3 3
4   -This is a collection of miscellaneous tools that I have made over time. No really, they have no use as far as I am concerned! :)
  4 +This is a collection of miscellaneous tools that I have made over time. No really, they have no use as far as I am concerned
3  rot-tools/README.md
Source Rendered
... ... @@ -1,5 +1,4 @@
1 1 rot-tools
2 2 ==========
3 3
4   - A quick suite of ROT13 and 18 tools which I made during a spare 10 minutes :)
5   - EDIT: I am experimenting with other languages at the moment, so I am porting some of my programs :)
  4 + A quick suite of ROT13 and 18 tools which I made during a spare 10 minutes
22 rot-tools/rot13.c
... ... @@ -1,21 +1,15 @@
1 1 #include <stdio.h>
  2 +#include <ctype.h>
2 3
3   -int main(c, t)
  4 +int main(c)
4 5 {
5   - while((c = getchar()) != 10)
6   - if((c >= 78 && c < 92) || (c >= 110))
7   - {
8   - t = 0;
9   - for(;(c >= 78 && c < 92) || (c >= 110);--c)
10   - ++t;
11   - if(c > 92)
12   - putchar(96 + t);
  6 + while((c = getchar()) != EOF)
  7 + if(isalpha(c))
  8 + if((c < 78) || (96 < c && c < 110))
  9 + putchar(c + 13);
13 10 else
14   - putchar(64 + t);
15   - }
16   - else if(c != 32)
17   - putchar(c + 13);
  11 + putchar(c - 13);
18 12 else
19   - putchar(32);
  13 + putchar(c);
20 14 return 0;
21 15 }
37 rot-tools/rot18.c
... ... @@ -1,30 +1,21 @@
1 1 #include <stdio.h>
  2 +#include <ctype.h>
2 3
3   -int main(c, t)
  4 +int main(c)
4 5 {
5   - while((c = getchar()) != 10)
6   - if((c >= 78 && c < 92) || (c >= 110))
7   - {
8   - t = 0;
9   - for(;(c >= 78 && c < 92) || (c >= 110);--c)
10   - ++t;
11   - if(c > 92)
12   - putchar(96 + t);
  6 + while((c = getchar()) != EOF)
  7 + if(isalpha(c))
  8 + if((c < 78) || (96 < c && c < 110))
  9 + putchar(c + 13);
13 10 else
14   - putchar(64 + t);
15   - }
16   - else if(c != 32 && c > 60)
17   - putchar(c + 13);
18   - else if(c == 32)
19   - putchar(c);
20   - else if(c >= 53)
21   - {
22   - t = 0;
23   - for(;c >= 54;--c)
24   - ++t;
25   - putchar(48 + t);
26   - }
  11 + putchar(c - 13);
27 12 else
28   - putchar(c + 5);
  13 + if(c < 48)
  14 + putchar(c);
  15 + else
  16 + if((c > 32 && c < 53))
  17 + putchar(c + 5);
  18 + else
  19 + putchar(c - 5);
29 20 return 0;
30 21 }
15 rot-tools/rot47.c
... ... @@ -0,0 +1,15 @@
  1 +#include <stdio.h>
  2 +
  3 +int main ()
  4 +{
  5 + int c;
  6 + while ((c = getchar()) != EOF)
  7 + if(32 < c)
  8 + if(c < 80)
  9 + putchar(c + 47);
  10 + else
  11 + putchar(c - 47);
  12 + else
  13 + putchar(c);
  14 + return 0;
  15 +}

0 comments on commit 0e93a22

Please sign in to comment.
Something went wrong with that request. Please try again.