xref: /titanic_41/usr/src/lib/libldap5/sources/ldap/common/secutil.c (revision 70025d765b044c6d8594bb965a2247a61e991a99)
1 /*
2  * Copyright (c) 2001 by Sun Microsystems, Inc.
3  * All rights reserved.
4  */
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 
8 #include <stdlib.h>
9 #include <string.h>
10 #include <ctype.h>
11 
12 static char	hexdig[] = "0123456789abcdef";
13 
14 char* hexa_print(char *aString, int aLen)
15 {
16 	char *res;
17 	int i =0;
18 
19 	if ((res = (char *)calloc (aLen*2 + 1, 1 )) == NULL){
20 		return (NULL);
21 	}
22 	for (;;){
23 		if (aLen < 1)
24 			break;
25 		res[i] = hexdig[ ( *aString & 0xf0 ) >> 4 ];
26 		res[i + 1] = hexdig[ *aString & 0x0f ];
27 		i+= 2;
28 		aLen--;
29 		aString++;
30 	}
31 	return (res);
32 }
33