122347Spst/* btoh.c: The opiebtoh() 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
1122347Spst	Created by cmetz for OPIE 2.3.
1222347Spst*/
1322347Spst
1422347Spst#include "opie_cfg.h"
1522347Spst#include "opie.h"
1622347Spst
1722347Spststatic char hextochar[16] =
1822347Spst{'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
1922347Spst
2092906Smarkmchar *opiebtoh FUNCTION((out, in), char *out AND struct opie_otpkey *inkey)
2122347Spst{
2222347Spst  int i;
2322347Spst  char *c = out;
2492906Smarkm  unsigned char *in = (unsigned char *)inkey;
2522347Spst
2622347Spst  for (i = 0; i < 4; i++) {
2722347Spst    *(c++) = hextochar[((*in) >> 4) & 0x0f];
2822347Spst    *(c++) = hextochar[(*in++) & 0x0f];
2922347Spst    *(c++) = hextochar[((*in) >> 4) & 0x0f];
3022347Spst    *(c++) = hextochar[(*in++) & 0x0f];
3122347Spst    *(c++) = ' ';
3222347Spst  }
3322347Spst  *(--c) = 0;
3422347Spst
3522347Spst  return out;
3622347Spst}
37