MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / BinToHex

Function BinToHex

Libraries/unrar/strfn.cpp:201–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199
200
201void BinToHex(const byte *Bin,size_t BinSize,char *HexA,wchar *HexW,size_t HexSize)
202{
203 uint A=0,W=0; // ASCII and Unicode hex output positions.
204 for (uint I=0;I<BinSize;I++)
205 {
206 uint High=Bin[I] >> 4;
207 uint Low=Bin[I] & 0xf;
208 uint HighHex=High>9 ? 'a'+High-10:'0'+High;
209 uint LowHex=Low>9 ? 'a'+Low-10:'0'+Low;
210 if (HexA!=NULL && A<HexSize-2) // Need space for 2 chars and final zero.
211 {
212 HexA[A++]=(char)HighHex;
213 HexA[A++]=(char)LowHex;
214 }
215 if (HexW!=NULL && W<HexSize-2) // Need space for 2 chars and final zero.
216 {
217 HexW[W++]=HighHex;
218 HexW[W++]=LowHex;
219 }
220 }
221 if (HexA!=NULL && HexSize>0)
222 HexA[A]=0;
223 if (HexW!=NULL && HexSize>0)
224 HexW[W]=0;
225}
226
227
228#ifndef SFX_MODULE

Callers 2

TestRijndaelFunction · 0.85
ListFileHeaderFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestRijndaelFunction · 0.68