1#include <stdint.h> 2#include <stdlib.h> 3#include <string.h> 4 5static const char digits[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 6 7long a64l(const char* s) { 8 int e; 9 uint32_t x = 0; 10 for (e = 0; e < 36 && *s; e += 6, s++) 11 x |= (strchr(digits, *s) - digits) << e; 12 return x; 13} 14 15char* l64a(long x0) { 16 static char s[7]; 17 char* p; 18 uint32_t x = x0; 19 for (p = s; x; p++, x >>= 6) 20 *p = digits[x & 63]; 21 *p = 0; 22 return s; 23} 24