Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2014-12-27 20:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls