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>
16 static char *c_xlate
= "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
20 * Create a base 32 string representation of a number.
21 * The supplied string 's' must be at least 8 bytes long.
22 * Use the b32_string_t tyepdef.
25 int_to_base32(b32_string_t s
, int a
)
41 for (; j
>= 0; j
-= 5) {
44 break; /* found highest bits set. */
46 s
[i
++] = c_xlate
[n
>> j
];
51 for (; j
>= 0; j
-= 5) {
53 s
[i
++] = c_xlate
[n
>> j
];
62 base32_to_int(char *s
)
71 n
= 10 + (int)(*s
- 'A');
73 result
= (result
<< 5) + n
;