Hello, I am trying to solve the problem: http://projecteuler.net/index.php?section=problems&id=59

The task is to decrypt ASCII text using brute force. The password is 3 characters long, all lower caps.

So the code I have here will print out a small portion of the text using brute force of all versions of [a..w][a..w][a..w]. But I am having a problem here:
until ($numcount==24) { $pass = @list[$count3].@list[$count2].@list[$count1]; #a combination o +f three letters $foo = "@s[$numcount]"; #a ASCII character to try to decrypt $karp = xor_buf($foo,$pass); # put these together using the XOR module push @lister,$karp; $numcount++; }
The line where I use the XOR module to combine the two strings isn't working. For example, $pass = abc; but the code output doesn't change when the last letter changes, so the output will be the same when $pass=abd or $pass=abx. But if the first or second letter change, the output changes too. I tested and saw that for some reason, the XOR module doesn't read the last letter, only the two first ones, but when I try a simple version only with strings, it works.

NB! The code is using "while" because it worked even less with "foreach" loops(it only read the first letter).

Any help is immencely appreciated :) Thanks.

Output sample:
0M@O@KKHM@ILBHAHIHILABCLANLJKKCLNLANMOHJHNKHHM@BLMAM@BLMHIAKIMHHNKKH - +- zyy 0M@O@KKHM@ILBHAHIHILABCLANLJKKCLNLANMOHJHNKHHM@BLMAM@BLMHIAKIMHHNKKH - +- zyz 0MCOCKHHMCIOBHBHJHILBBCLBNOJKHCLMLBNMOHIHMKHKMCBOMBMCBOMKIBKJMKHMKHH - +- zza 0MCOCKHHMCIOBHBHJHILBBCLBNOJKHCLMLBNMOHIHMKHKMCBOMBMCBOMKIBKJMKHMKHH - +- zzb
Full code:
#!/usr/bin/perl use Math::XOR; #$outfile = "output.txt"; #open(HANDLE, ">>$outfile"); @list = (a..z); $count1 = 0; $count2 = 0; $count3 = 0; @s=(79,59,12,2,79,35,8,28,20,2,3,68,8,9,68,45,0,12,9,67,68,4,7,5,23,27 +,1,21,79,85,78,79,85,71,38,10,71,27,12,2,79,6,2,8,13,9); until ($count3==26) { until ($count2==26) { until ($count1==26) { until ($numcount==40) { $pass = @list[$count3].@list[$count2].@list[$count1]; $foo = "@s[$numcount]"; $karp = xor_buf($foo, $pass); push @lister,$karp; $numcount++; } print @lister," -- $pass\n"; @lister = 0; $numcount=0; $count1++; } $count1=0; $count2++; } $count2=0; $count3++; }

In reply to Math::XOR problem by kuratkull

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.