Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^3: strings to number and XOR

by almut (Canon)
on Oct 07, 2009 at 18:23 UTC ( #799773=note: print w/ replies, xml ) Need Help??

in reply to Re^2: strings to number and XOR
in thread strings to number and XOR

I've tried directly with $key++

The problem with Perl's string-increment is that the string has to match the pattern /^[a-zA-Z]*[0-9]*\z/ for it to work...(see perlop).  So you'd have to increment the corresponding numeric value, e.g.

$key = "\x4f\xcb"; for (1..10) { $key = pack('n',unpack('n',$key)+1); # ++ print unpack("H*", $key), "\n"; } __END__ 4fcc 4fcd 4fce 4fcf 4fd0 4fd1 4fd2 4fd3 4fd4 4fd5

Comment on Re^3: strings to number and XOR
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://799773]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2015-11-27 19:58 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (731 votes), past polls