Assistance needed with cyphertext in python

  • (4 Pages)
  • +
  • « First
  • 2
  • 3
  • 4

46 Replies - 4577 Views - Last Post: 06 April 2013 - 08:31 PM Rate Topic: -----

#46 blueshrapnel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-April 13

Re: Assistance needed with cyphertext in python

Posted 05 April 2013 - 03:11 PM

Hi, I'm also doing this course, and finding that this programming assignment has really challenged what I thought I knew or didn't know about programming. In fact I've never had to deal with binary, hexadecimal, etc... fortunately I have received some help in that department from a fellow student, now understand a whole lot more about computer math!

All that aside... I have created a list of ciphers, ci so if I take c1 ^ c2, c1 ^ c3, c1 ^ c4, c1 ^ c5, .... xor c1 against all other ciphers... then identify which characters have changed case.... if a char[l] in c1 has changed case when xor'd against all other ciphers, then char[l] in c1 is a space. That's what I'm trying to do... then dive into frequency analysis...

I'm looking for an elegant way of doing that... without unnecessarily converting between hex, ascii, etc... we're given the CT in hex, I can XOR in hex. But then when I want to char[l]&'00100000' I need to parse the hex value in pairs of digits....

A = "breAd"
hexA = a.encode(a)
for c in hexA:
    print c


it just prints the individual digits, and not the hex pairs.... I've got round that by creating a list of ascii codes for each characters... the char[l] idea.

for cc in b.decode('hex'):
	print bin(ord(cc)),' \t',
	print ord(cc)&int('00100000',2)



Is there an easier / more elegant way?

Of course, if I want to automate it, I need to know if the case has changed.....

I'm no where near a solution yet, but thoroughly enjoying the challenge, it's a great exercise in programming.

Thanks, so far this thread has cleared some things up for me.
Was This Post Helpful? 0
  • +
  • -

#47 tpaskell  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 125
  • Joined: 21-March 13

Re: Assistance needed with cyphertext in python

Posted 06 April 2013 - 08:31 PM

Yes I have to say jon has been the perfect mentor/teacher for me. he has put extra time with me, seeing as I am a slow learner, and this has helped me immensely. I am glad this topic has helped you too. Yet again hats off to you jon!
Was This Post Helpful? 0
  • +
  • -

  • (4 Pages)
  • +
  • « First
  • 2
  • 3
  • 4