Digital Raven (digitalraven) wrote,
Digital Raven

  • Mood:
  • Music:

Project stuff

I finally figured the last problem with my program now it's all subroutined out. I include this in the hopes that other Perl people won't make the same stupid mistake.

So I'm trying to copy a list-of-lists, then do something with the new list. Bear in mind that I'm reasonably new to working with LoLs and thus don't know why, once I have finished adding columns to the second one, the columns are also present in the first. That's becausee I was using

@NewLoL = @LoL;

#add some columns to @NewLoL, actual code is 
#incidental but it was to compute the full 4x44 key block 
#for the AES. 

#getdim is a routine to return the number of rows and
#columns in a LoL
($row, $col) = getdim(@LoL);

print "$col";

$col was turning out to be 44, when to my eyes it should have been 4. Wrong. After the first line, both @lol and @NewLoL were lists containing references to the anonymous lists that was the rows. As I was adding to those rows when I manipulated @NewLoL, the arrays were growing, and thus when I used @LoL, these were the same arrays referred to in @NewLoL.

Only once I had implemented a very fast deep copy which would get the first 4x4 of @NewLoL did the program work, and it took half an hour afterwards of hard thinking for me to finally grok why I had needed to perform a deep copy.

Yeah, I'm an idiot. But I'll never make that mistake again.

Now, I relax for some and star working on decryption. Of course, I need to find the inverse Sbox as it's not provided anywhere in the book and I'm fucked if I'm doing yet more matrix multiplication in GF(2^8). But this should now be easy.

  • Update

    Gigantor on Friday was great. Unfortunately, it also meant going to bed at 4am. I'm getting far, far too old for that shit. Especially when the…

  • A Time For Change

    Samhuinn's always a time of endings, but it's a time of new beginnings. Summer ends, but winter begins. It's all a cycle. And frankly, it's a good…

  • Weekends

    That was... intense. I had Friday off. I put this time to good use by sleeping in (because I've been running on too-little-sleep for the past month)…

  • Post a new comment


    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded