Can anyone see where the following routine is going wrong, it is part of an encryption utility I am putting together where I need to convert an array of bytes into a string representation, I'm using 2 character hex strings which keeps it readable and suits the mechanism I am using.
I have this routine I found on the net (www.xploiter.com) which looked like it would work but it keeps raising access violations:
procedure BytesToHexStr(var hHexStr: String; pbyteArray: PByte;
InputLength: WORD); Const HexChars : Array[0..15] of Char = '0123456789ABCDEF'; var i, j: WORD; begin SetLength(hHexStr, (InputLength * 2)); FillChar(hHexStr, sizeof(hHexStr), #0);
I think you meant:
FillChar(hHexStr, Length(hHexStr), #0);
Also, you may run into problems with Borland's Longstrings when you've told them that they're of a particular length but they're filled with nulls all along that length.
I think maybe it confuses the logic that keeps the string "null terminated".
Spaces seem to work better for padded out strings like this.
HTH
Stephen Posey [EMAIL PROTECTED]
_______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

