zhicheng / base64 Goto Github PK
View Code? Open in Web Editor NEWbase64 c implementation
base64 c implementation
Base64 C Implementation License: Public Domain
If the encoded data ends with = or == it is impossible to tell the size from output of base64_decode() alone. It would be more convenient if base64_decode() returned j (size of the decoded array) instead of the constant BASE64_OK.
#define BASE64_DECODE_OUT_SIZE(s) ((unsigned int)(((s) / 4) * 3))
dec = malloc(BASE64_DECODE_OUT_SIZE(32));
base_decode(enc, enc_len, dec);
according to base64.c line 160;
out[j] = '\0'; // if not plus 1, out[j] is out of bound
maybe define the macro as follow:
#define BASE64_DECODE_OUT_SIZE(s) ((unsigned int)(((s) / 4) * 3 + 1))
Hello! If i want to encrypt some data about Hex. May I use Hex format encrypt with base64? And could I get decrypted data in Hex format. Thank you!
Hi, i have tried this with utf8 string in russian "АБГДЕ", but got error
Expression: memcmp(encode_out, decode, decodelen) == 0
This application has requested the Runtime to terminate it in an unusual way.
Should it work with it, or any workaround/ideas? Thanks.
My GCC complains compiling base64.c because we're using a signed char as a subscript:
base64.c: In function 'base64_decode':
base64.c:138:15: error: array subscript has type 'char' [-Werror=char-subscripts]
c = base64de[in[i]];
^
cc1: all warnings being treated as errors
This change fixes it for me... casting is unpleasant but it's the simplest alternative.
--- a/base64.c 2019-01-11 16:51:12.495365424 -0500
+++ b/base64.c 2019-01-11 17:21:46.674386800 -0500
@@ -135,7 +135,7 @@
return 0;
}
- c = base64de[in[i]];
+ c = base64de[(unsigned char)in[i]];
if (c == 255) {
return 0;
}
// base64.h
#ifdef __cplusplus
extern "C"{
#endif
...
#ifdef
}
#endif
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.