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>
18 static char *c_xlate = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
22 * Create a base 32 string representation of a number.
23 * The supplied string 's' must be at least 8 bytes long.
24 * Use the b32_string_t tyepdef.
27 int_to_base32(b32_string_t s, int a)
43 for (; j >= 0; j -= 5) {
46 break; /* found highest bits set. */
48 s[i++] = c_xlate[n >> j];
53 for (; j >= 0; j -= 5) {
55 s[i++] = c_xlate[n >> j];
64 base32_to_int(char *s)
73 n = 10 + (int)(*s - 'A');
75 result = (result << 5) + n;