Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: XOR'ing calculate a hex checksum

by halley (Prior)
on Jan 28, 2008 at 17:32 UTC ( #664720=note: print w/replies, xml ) Need Help??

in reply to XOR'ing to calculate a hex checksum

Don't do math in terms of digits or strings. Do math in terms of numbers. Digits are just a way of viewing numbers, they aren't numbers themselves.

You appear to be converting all your incoming bytes into hex before we even get to look at it in your checksum() routine, and then going through some painful conversion work to turn the pairs of hex digits back into bytes. I'm going to ignore that, and assume you have an array of @bytes instead.

my $total = 0; $total += $_ for @bytes; $check = ($total & 0xFF) ^ 0xFF;

Once you have your check value, then you can decide how to display it (if it needs displaying at all).

[ e d @ h a l l e y . c c ]

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://664720]
[marto]: in the sense that for various values of "a while ago" it would not have been possible (and arguable still isn't) to have a fingerprint of every piece of commercially released music to compare against.
[marto]: a co-worker refers to the late 1980s as "a while ago"
[Veltro]: Like I said before, I ment the solution as a whole
[Veltro]: People thought it was not possible.
[marto]: and until recently it wasn't and arguable (for some samples) probably isn't
[Veltro]: How did we get here? Oh yeah, advertisement. So let's get back there. What I ment to say is that I think it is possible to create an algorithm that filters out advertisement
[Veltro]: And yes, maybe your decoder needs the cloud to do so.

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2018-05-24 12:15 GMT
Find Nodes?
    Voting Booth?