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 <afsconfig.h>
11 #include <afs/param.h>
17 #if defined(AFS_NAMEI_ENV)
18 #include <sys/types.h>
21 /* This version of base64 gets it right and starts converting from the low
22 * bits to the high bits.
24 /* This table needs to be in lexical order to efficiently map back from
25 * characters to the numerical value.
27 static char c_xlate[80] =
28 "+=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
31 * Create a base 64 string representation of a number.
32 * The supplied string 's' must be at least 12 bytes long.
33 * lb64_string in stds.h provides a typedef to get the length.
37 int64_to_flipbase64(lb64_string_t s, afs_int64 a)
40 int64_to_flipbase64(lb64_string_t s, u_int64_t a)
54 for (n = a & 0x3f; a; n = ((a >>= 6) & 0x3f)) {
63 /* Mapping: +=0, ==1, 0-9 = 2-11, A-Z = 12-37, a-z = 38-63 */
66 flipbase64_to_int64(char *s)
69 flipbase64_to_int64(char *s)
81 for (shift = 0; *s; s++, shift += 6) {
87 n = 2 + (int)(*s - '0');
88 } else if (*s <= 'Z') {
89 n = 12 + (int)(*s - 'A');
90 } else if (*s <= 'z') {
91 n = 38 + (int)(*s - 'a');
100 #endif /* AFS_NAMEI_ENV */