misc.c (91754) | misc.c (220497) |
---|---|
1/* 2 * Copyright (c) 1999 3 * University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 14 unchanged lines hidden (view full) --- 23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1999 3 * University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 14 unchanged lines hidden (view full) --- 23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/lib/libcrypt/misc.c 91754 2002-03-06 17:18:09Z markm $"); | 31__FBSDID("$FreeBSD: head/lib/libcrypt/misc.c 220497 2011-04-09 14:02:04Z markm $"); |
32 33#include <sys/types.h> 34 35#include "crypt.h" 36 37static char itoa64[] = /* 0 ... 63 => ascii - 64 */ 38 "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 39 40void 41_crypt_to64(char *s, u_long v, int n) 42{ 43 while (--n >= 0) { 44 *s++ = itoa64[v&0x3f]; 45 v >>= 6; 46 } 47} | 32 33#include <sys/types.h> 34 35#include "crypt.h" 36 37static char itoa64[] = /* 0 ... 63 => ascii - 64 */ 38 "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 39 40void 41_crypt_to64(char *s, u_long v, int n) 42{ 43 while (--n >= 0) { 44 *s++ = itoa64[v&0x3f]; 45 v >>= 6; 46 } 47} |
48 49void 50b64_from_24bit(uint8_t B2, uint8_t B1, uint8_t B0, int n, int *buflen, char **cp) 51{ 52 uint32_t w; 53 int i; 54 55 w = (B2 << 16) | (B1 << 8) | B0; 56 for (i = 0; i < n; i++) { 57 **cp = itoa64[w&0x3f]; 58 (*cp)++; 59 if ((*buflen)-- < 0) 60 break; 61 w >>= 6; 62 } 63} |
|