btoa8.c revision 296373
1221167Sgnn/* btoa8.c: The opiebtoa8() library function. 2221167Sgnn 3221167Sgnn%%% copyright-cmetz-96 4221167SgnnThis software is Copyright 1996-2001 by Craig Metz, All Rights Reserved. 5221167SgnnThe Inner Net License Version 3 applies to this software. 6221167SgnnYou should have received a copy of the license with this software. If 7221167Sgnnyou didn't get a copy, you may request one from <license@inner.net>. 8221167Sgnn 9221167Sgnn History: 10221167Sgnn 11221167Sgnn Modified by cmetz for OPIE 2.4. Use struct opie_otpkey for binary arg. 12221167Sgnn Created by cmetz for OPIE 2.3 (quick re-write). 13221167Sgnn*/ 14221167Sgnn 15221167Sgnn#include "opie_cfg.h" 16221167Sgnn#include "opie.h" 17221167Sgnn 18221167Sgnnstatic char hextochar[16] = 19221167Sgnn{'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; 20221167Sgnn 21221167Sgnnchar *opiebtoa8 FUNCTION((out, in), char *out AND struct opie_otpkey *inkey) 22221167Sgnn{ 23221167Sgnn int i; 24221167Sgnn unsigned char *in = (unsigned char *)inkey; 25221167Sgnn char *c = out; 26221167Sgnn 27221167Sgnn for (i = 0; i < 8; i++) { 28221167Sgnn *(c++) = hextochar[((*in) >> 4) & 0x0f]; 29221167Sgnn *(c++) = hextochar[(*in++) & 0x0f]; 30221167Sgnn } 31221167Sgnn *c = 0; 32221167Sgnn 33221167Sgnn return out; 34221167Sgnn} 35221167Sgnn