String to 16

xiaoxiao2021-03-06  107

String StrtoHEX (String STR)

{

String strTemp = "";

IF (str = "")

""; "

Byte [] btemp = system.text.Encoding.default.getbytes (STR);

For (int i = 0; i

{

Strtemp = Btemp [i] .tostring ("x");

}

Return strtemp;

}

The following is taken from 9CBS, Byte [] turn String soon, no test

Char [] hexdigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'c', 'd', 'e', ​​'f'};

String tohexstring (byte [] Bytes)

{

Char [] chars = new char [bytes.length * 2];

For (int i = 0; i

{

INT b = bytes [i];

Chars [i * 2] = HEXDIGITS [B >> 4];

Chars [i * 2 1] = HEXDIGITS [B & 0xF];

}

Return New String (Chars);

}

转载请注明原文地址:https://www.9cbs.com/read-104345.html

New Post(0)