2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afs/param.h>
12 #if defined(AFS_NAMEI_ENV)
13 #include <sys/types.h>
16 /* This version of base64 gets it right and starts converting from the low
17 * bits to the high bits.
19 /* This table needs to be in lexical order to efficiently map back from
20 * characters to the numerical value.
22 static char c_xlate[80] =
23 "+=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
26 * Create a base 64 string representation of a number.
27 * The supplied string 's' must be at least 12 bytes long.
28 * lb64_string in stds.h provides a typedef to get the length.
30 char *int64_to_flipbase64(lb64_string_t s, afs_int64 a)
39 for (n = a & 0x3f; a; n = ((a>>=6) & 0x3f)) {
48 /* Mapping: +=0, ==1, 0-9 = 2-11, A-Z = 12-37, a-z = 38-63 */
49 int64_t flipbase64_to_int64(char *s)
55 for (shift = 0; *s; s++, shift += 6) {
57 else if (*s == '=') n = 1;
59 n = 2 + (int)(*s - '0');
62 n = 12 + (int)(*s - 'A');
65 n = 38 + (int)(*s - 'a');
74 #endif /* AFS_NAMEI_ENV */