My question is, how does the BT client go from plain text to that? The
BT protocol spec says that pieces of data get SHA1’d, but I’ve never
seen a SHA1 hash look like that.
What am I missing?
In case the sample characters I pasted don’t show up right, here’s a
screen shot:
My question is, how does the BT client go from plain text to that? The
BT protocol spec says that pieces of data get SHA1’d, but I’ve never
seen a SHA1 hash look like that.
That sort of depends how you display your SHA1 hash. The result will
just be 20 random looking bytes (as you’ve got before), which doesn’t
display particularly nicely, which is why it’s often written out in
hex. However if it’s never going to be read by anything approaching a
human you might as well just store the 20 bytes without trying to
encode them in anyway.
That sort of depends how you display your SHA1 hash. The result will
just be 20 random looking bytes (as you’ve got before), which doesn’t
display particularly nicely, which is why it’s often written out in
hex. However if it’s never going to be read by anything approaching a
human you might as well just store the 20 bytes without trying to
encode them in anyway.
Wow Frederick, you just opened my eyes! Thank you!
You said…
…which is why it’s often written out in hex.
And on a whim I tried:
Digest::SHA1.digest(…)
And lo’ and behold, I got much more bizarre looking output:
The output, while more similar to what Transmission is generating, isn’t
quite as “funky.”
Scatch that “quite as funky” bit. I’ve hashed the SAME content and
gotten different results that what Transmission is generating. So I’m
still doing something wrong.
That’s an interesting operation, but nay, no directional change. (Also,
pasting it into IRB causes my machine to beep and pause. Dunno why
though. Perhaps the characters being pasted mean something special to
Ruby?)
I asked a friend of mine and he said that if you dump the output of the
digest method directly to a file, you’ll get the funky output.
My guess is console does some kind of conversion – possibly with
character encoding?