Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libcrypt/misc.c
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
while (--n >= 0) { | while (--n >= 0) { | ||||
*s++ = itoa64[v&0x3f]; | *s++ = itoa64[v&0x3f]; | ||||
v >>= 6; | v >>= 6; | ||||
} | } | ||||
} | } | ||||
void | void | ||||
b64_from_24bit(uint8_t B2, uint8_t B1, uint8_t B0, int n, int *buflen, char **cp) | b64_from_24bit(uint8_t B2, uint8_t B1, uint8_t B0, int n, char **cp) | ||||
{ | { | ||||
uint32_t w; | uint32_t w; | ||||
int i; | int i; | ||||
w = (B2 << 16) | (B1 << 8) | B0; | w = (B2 << 16) | (B1 << 8) | B0; | ||||
for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
**cp = itoa64[w&0x3f]; | **cp = itoa64[w&0x3f]; | ||||
(*cp)++; | (*cp)++; | ||||
if ((*buflen)-- < 0) | |||||
break; | |||||
w >>= 6; | w >>= 6; | ||||
} | } | ||||
} | } |