mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-23 10:29:58 +01:00
25 lines
471 B
C
25 lines
471 B
C
|
int
|
||
|
hextobyte (const char *s)
|
||
|
{
|
||
|
int c;
|
||
|
|
||
|
if ( *s >= '0' && *s <= '9' )
|
||
|
c = 16 * (*s - '0');
|
||
|
else if ( *s >= 'A' && *s <= 'F' )
|
||
|
c = 16 * (10 + *s - 'A');
|
||
|
else if ( *s >= 'a' && *s <= 'f' )
|
||
|
c = 16 * (10 + *s - 'a');
|
||
|
else
|
||
|
return -1;
|
||
|
s++;
|
||
|
if ( *s >= '0' && *s <= '9' )
|
||
|
c += *s - '0';
|
||
|
else if ( *s >= 'A' && *s <= 'F' )
|
||
|
c += 10 + *s - 'A';
|
||
|
else if ( *s >= 'a' && *s <= 'f' )
|
||
|
c += 10 + *s - 'a';
|
||
|
else
|
||
|
return -1;
|
||
|
return c;
|
||
|
}
|