mirror of https://github.com/PurpleI2P/i2pd.git
I2P: End-to-End encrypted and anonymous Internet
https://i2pd.website/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.2 KiB
64 lines
2.2 KiB
11 years ago
|
#ifndef BASE64_H
|
||
|
#define BASE64_H
|
||
|
|
||
|
#include <inttypes.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
namespace i2p
|
||
|
{
|
||
9 years ago
|
namespace util
|
||
11 years ago
|
{
|
||
|
|
||
9 years ago
|
|
||
|
/*
|
||
|
* Base64 encodes an array of bytes.
|
||
9 years ago
|
* @return the number of characters written to the output buffer
|
||
9 years ago
|
* @param InBuffer array of input bytes to be encoded
|
||
|
* @param InCount length of the input array
|
||
9 years ago
|
* @param OutBuffer array to store output characters
|
||
9 years ago
|
* @param len length of the output buffer
|
||
9 years ago
|
* @note zero is returned when the output buffer is too small
|
||
9 years ago
|
*/
|
||
10 years ago
|
size_t ByteStreamToBase64 (const uint8_t * InBuffer, size_t InCount, char * OutBuffer, size_t len);
|
||
9 years ago
|
|
||
|
/**
|
||
|
* Decodes base 64 encoded data to an array of bytes.
|
||
9 years ago
|
* @return the number of bytes written to the output buffer
|
||
9 years ago
|
* @param InBuffer array of input characters to be decoded
|
||
|
* @param InCount length of the input array
|
||
9 years ago
|
* @param OutBuffer array to store output bytes
|
||
9 years ago
|
* @param len length of the output buffer
|
||
|
* @todo Do not return a negative value on failure, size_t could be unsigned.
|
||
9 years ago
|
* @note zero is returned when the output buffer is too small
|
||
9 years ago
|
*/
|
||
10 years ago
|
size_t Base64ToByteStream (const char * InBuffer, size_t InCount, uint8_t * OutBuffer, size_t len );
|
||
9 years ago
|
|
||
10 years ago
|
const char * GetBase64SubstitutionTable ();
|
||
|
|
||
9 years ago
|
/**
|
||
|
* Decodes base 32 encoded data to an array of bytes.
|
||
|
* @return the number of bytes written to the output buffer
|
||
|
* @param inBuf array of input characters to be decoded
|
||
|
* @param len length of the input buffer
|
||
|
* @param outBuf array to store output bytes
|
||
|
* @param outLen length of the output array
|
||
9 years ago
|
* @note zero is returned when the output buffer is too small
|
||
9 years ago
|
*/
|
||
10 years ago
|
size_t Base32ToByteStream (const char * inBuf, size_t len, uint8_t * outBuf, size_t outLen);
|
||
9 years ago
|
|
||
|
/**
|
||
|
* Base 32 encodes an array of bytes.
|
||
|
* @return the number of bytes written to the output buffer
|
||
|
* @param inBuf array of input bytes to be encoded
|
||
|
* @param len length of the input buffer
|
||
|
* @param outBuf array to store output characters
|
||
|
* @param outLen length of the output array
|
||
9 years ago
|
* @note zero is returned when the output buffer is too small
|
||
9 years ago
|
*/
|
||
|
size_t ByteStreamToBase32 (const uint8_t * inBuf, size_t len, char * outBuf, size_t outLen);
|
||
11 years ago
|
}
|
||
|
}
|
||
|
|
||
|
#endif
|
||
|
|