about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJoe DF <joedf@live.ca>2018-07-12 10:09:50 -0400
committerJoe DF <joedf@live.ca>2018-07-12 10:09:50 -0400
commit0eceb10024d66033c7a567387a80e664c5ebb4e6 (patch)
treeb652d47aa95db92e22abc25d78e5a87b2953662c
parentf2c2b2bb0d2aa0046784cfb708e3c918e8f24d4b (diff)
downloadbase64-0eceb10024d66033c7a567387a80e664c5ebb4e6.tar.gz
Usage examples and info
-rw-r--r--BuildRun.bat13
-rw-r--r--README.md3
-rw-r--r--b64f.c44
-rw-r--r--picture.pngbin0 -> 27379 bytes
4 files changed, 59 insertions, 1 deletions
diff --git a/BuildRun.bat b/BuildRun.bat
index 874ac75..121bd4b 100644
--- a/BuildRun.bat
+++ b/BuildRun.bat
@@ -3,5 +3,16 @@ mkdir bin 2>NUL
 cls
 echo compiling...
 gcc test.c base64.c -o bin\test.exe
+gcc b64f.c base64.c -o bin\b64f.exe
 echo running...
-bin\test.exe
\ No newline at end of file
+bin\test.exe
+echo.
+echo Encoding test image "picture.png" to "picture.b64.txt"...
+bin\b64f.exe e picture.png picture.b64.txt
+echo.
+echo Decoding test image from "picture.b64.txt" to "picture.b64.png"...
+bin\b64f.exe d picture.b64.txt picture.b64.png
+echo.
+echo Done.
+echo See files manually if the programmed works correctly.
+pause
\ No newline at end of file
diff --git a/README.md b/README.md
index 57154cc..58fba4b 100644
--- a/README.md
+++ b/README.md
@@ -8,3 +8,6 @@ Released under the MIT License
   
 Thank you for inspiration:  
 http://www.codeproject.com/Tips/813146/Fast-base-functions-for-encode-decode  
+
+## Usage
+Simply include `base64.c` and `base64.h` in your project and see `base64.h` for instructions.
\ No newline at end of file
diff --git a/b64f.c b/b64f.c
new file mode 100644
index 0000000..895dc9e
--- /dev/null
+++ b/b64f.c
@@ -0,0 +1,44 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "base64.h"
+
+int lower(int a);
+
+int main(int argc,char** argv) {
+	
+	puts("\nbase64.c [Encode/Decode]");
+	puts("------------------------------------");
+	printf("Use the following to encode:\n\t%s e(ncode) IN_filepath OUT_filepath\n",argv[0]);
+	printf("Use the following to decode:\n\t%s d(ecode) IN_filepath OUT_filepath\n",argv[0]);
+	if (argc < 4) {
+		puts("\nERROR: not enough parameters...");
+		return 1;
+	}
+	char opt = lower(argv[1][0]);
+	int bcoded = 0;
+	switch(opt) {
+		case 'd':
+			puts("\nDECODING");
+			bcoded = b64_decodef(argv[2],argv[3]);
+			break;
+		case 'e':
+			puts("\nENCODING");
+			bcoded = b64_encodef(argv[2],argv[3]);
+			break;
+		default:
+			puts("\nINVALID OPTION");
+			bcoded = -1;
+	}
+	
+	printf("\nBytes encoded/decoded: %i\n",bcoded);
+	
+	return 0;
+}
+
+int lower(int a) { //https://stackoverflow.com/a/15709023/883015
+    if ((a >= 0x41) && (a <= 0x5A))
+        a |= 0x20; 
+    return a;  
+}
diff --git a/picture.png b/picture.png
new file mode 100644
index 0000000..6b7f5c9
--- /dev/null
+++ b/picture.png
Binary files differ