max on which class do you define it? do you have some tests? Stef On Dec 19, 2010, at 11:40 PM, Max Leske wrote:
I know how your feel. My code:
hexHashFrom: aByteString "#hex will omit a leading 0. If that's the case insert leading 0." ^aByteString asByteArray hex asLowercase forceTo: 40 paddingStartWith: $0
Max
On 19.12.2010, at 22:54, Sven Van Caekenberghe wrote:
Hi Geoffroy,
On 19 Dec 2010, at 21:55, Geoffroy Couprie wrote:
Hello all,
I get a strange behaviour while trying to print hexadecimal values of a string.
Context: I get a SHA1 hash from a binary stream, store it into a string, and I want to display that string (using asHex).
Problem: for values inferior to 16, the leading zero is ignored. (15 -> 'F' instead of '0F').
I could modify SmallInteger>>printStringBase: to always include the leading zero, but I fear I'm going to break a lot of code doing that. Is there a better way to fix my problem? apart from using directly the following: aStream do:[:val | val printStringBase:16 nDigits:2]
Best regards,
Geoffroy
Why would you not use the ByteArray>>#hex method ?
#(0 1 2 253 254 255) asByteArray hex
'000102fdfeff'
Sven