122347Spst/* btoa8.c: The opiebtoa8() library function.
222347Spst
329964Sache%%% copyright-cmetz-96
492906SmarkmThis software is Copyright 1996-2001 by Craig Metz, All Rights Reserved.
592906SmarkmThe Inner Net License Version 3 applies to this software.
622347SpstYou should have received a copy of the license with this software. If
722347Spstyou didn't get a copy, you may request one from <license@inner.net>.
822347Spst
922347Spst        History:
1022347Spst
1192906Smarkm	Modified by cmetz for OPIE 2.4. Use struct opie_otpkey for binary arg.
1222347Spst	Created by cmetz for OPIE 2.3 (quick re-write).
1322347Spst*/
1422347Spst
1522347Spst#include "opie_cfg.h"
1622347Spst#include "opie.h"
1722347Spst
1822347Spststatic char hextochar[16] =
1922347Spst{'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
2022347Spst
2192906Smarkmchar *opiebtoa8 FUNCTION((out, in), char *out AND struct opie_otpkey *inkey)
2222347Spst{
2322347Spst  int i;
2492906Smarkm  unsigned char *in = (unsigned char *)inkey;
2522347Spst  char *c = out;
2622347Spst
2722347Spst  for (i = 0; i < 8; i++) {
2822347Spst    *(c++) = hextochar[((*in) >> 4) & 0x0f];
2922347Spst    *(c++) = hextochar[(*in++) & 0x0f];
3022347Spst  }
3122347Spst  *c = 0;
3222347Spst
3322347Spst  return out;
3422347Spst}
35