summaryrefslogtreecommitdiff
path: root/usr/src/lib/libldap5/sources/ldap/common/secutil.c
blob: 7df5423e831732e18be68d026eefd0feb0617736 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
 * Copyright (c) 2001 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#include <stdlib.h>
#include <string.h>
#include <ctype.h>

static char	hexdig[] = "0123456789abcdef";

char* hexa_print(char *aString, int aLen)
{
	char *res;
	int i =0;
	
	if ((res = (char *)calloc (aLen*2 + 1, 1 )) == NULL){
		return (NULL);
	}
	for (;;){
		if (aLen < 1)
			break;
		res[i] = hexdig[ ( *aString & 0xf0 ) >> 4 ];
		res[i + 1] = hexdig[ *aString & 0x0f ];
		i+= 2;
		aLen--;
		aString++;
	}
	return (res);
}