Caveat: I know next to nothing about the DES algorithm so am not going to comment on it here.

so I came to the conclusion that I am not reading the input file as 8 byte chunks correctly or as them

Ordinarily, that would mean you would just look at the readInputToArray() subroutine. However, the lack of strict and the profusion of global variables (such as $bytes and @FileArray) is going to make the debugging very difficult. Please do yourself a massive favour and limit the scope of your variables and make your subroutines as self-contained as possible. eg. have readInputToArray() return @FileArray so that the subroutine can be tested in isolation.

All that said, this line is concerning me:

my $padding = "0" x $diff;

Unfamiliar as I am with DES, this shows that you are padding the read string with "0"s - that is a string with each character being ASCII character "0" (dec 48 or hex 0x30) when what I can only guess you actually want is dec 0 or hex 0x00 which is the ASCII NUL. Is this a/the flaw? You tell me :-)


In reply to Re: DES in Perl by hippo
in thread DES in Perl by TomY

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.