mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 02:38:09 +09:00
base64: Reformat _bin_to_base64()
Fixes T188
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit fe9991b3c6)
This commit is contained in:
@@ -234,9 +234,11 @@ static int get_equals(char *string) {
|
||||
}
|
||||
|
||||
/* thanks sysk for debugging my mess :) */
|
||||
static void _bin_to_base64(unsigned char *dest,
|
||||
const unsigned char source[3],
|
||||
int len)
|
||||
{
|
||||
#define BITS(n) ((1 << (n)) - 1)
|
||||
static void _bin_to_base64(unsigned char *dest, const unsigned char source[3],
|
||||
int len) {
|
||||
switch (len) {
|
||||
case 1:
|
||||
dest[0] = alphabet[(source[0] >> 2)];
|
||||
@@ -257,6 +259,7 @@ static void _bin_to_base64(unsigned char *dest, const unsigned char source[3],
|
||||
dest[3] = alphabet[source[2] & BITS(6)];
|
||||
break;
|
||||
}
|
||||
#undef BITS
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user