summaryrefslogtreecommitdiff
path: root/plugins/CryptoPP/src/base16.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/CryptoPP/src/base16.cpp')
-rw-r--r--plugins/CryptoPP/src/base16.cpp34
1 files changed, 14 insertions, 20 deletions
diff --git a/plugins/CryptoPP/src/base16.cpp b/plugins/CryptoPP/src/base16.cpp
index d28daf99a3..689d54c88a 100644
--- a/plugins/CryptoPP/src/base16.cpp
+++ b/plugins/CryptoPP/src/base16.cpp
@@ -1,15 +1,14 @@
#include "commonheaders.h"
-
-char *base16encode(const char *inBuffer, int count) {
-
- char *outBuffer = (char *) malloc(count*2+1);
+char *base16encode(const char *inBuffer, int count)
+{
+ char *outBuffer = (char *)malloc(count * 2 + 1);
char *outBufferPtr = outBuffer;
- BYTE *inBufferPtr = (BYTE *) inBuffer;
+ BYTE *inBufferPtr = (BYTE *)inBuffer;
- while(count){
- *outBufferPtr++ = encode16(((*inBufferPtr)>>4)&0x0F);
- *outBufferPtr++ = encode16((*inBufferPtr++)&0x0F);
+ while (count) {
+ *outBufferPtr++ = encode16(((*inBufferPtr) >> 4) & 0x0F);
+ *outBufferPtr++ = encode16((*inBufferPtr++) & 0x0F);
count--;
}
*outBufferPtr = '\0';
@@ -17,20 +16,19 @@ char *base16encode(const char *inBuffer, int count) {
return outBuffer;
}
-
-char *base16decode(const char *inBuffer, unsigned int *count) {
-
+char *base16decode(const char *inBuffer, unsigned int *count)
+{
char *outBuffer = (char *)mir_alloc(*count);
BYTE *outBufferPtr = (BYTE *)outBuffer;
bool big_endian = false;
- if (*inBuffer == '0' && *(inBuffer+1) == 'x') {
+ if (*inBuffer == '0' && *(inBuffer + 1) == 'x') {
inBuffer += *count;
big_endian = true;
*count -= 2;
}
- while(*count>1){
- BYTE c0,c1;
+ while (*count > 1) {
+ BYTE c0, c1;
if (big_endian) {
c1 = decode16(*--inBuffer);
c0 = decode16(*--inBuffer);
@@ -44,21 +42,17 @@ char *base16decode(const char *inBuffer, unsigned int *count) {
*count = 0;
return(NULL);
}
- *outBufferPtr++ = (c0<<4) | c1;
+ *outBufferPtr++ = (c0 << 4) | c1;
*count -= 2;
}
*outBufferPtr = '\0';
- *count = (int)(outBufferPtr-(BYTE *)outBuffer);
+ *count = (int)(outBufferPtr - (BYTE *)outBuffer);
return outBuffer;
}
-
char *base16decode(const char *inBuffer)
{
unsigned count = (unsigned)strlen(inBuffer);
return base16decode(inBuffer, &count);
}
-
-
-// EOF