Hacking Secret Ciphers with Python

(Ann) #1

404 http://inventwithpython.com/hacking


Email questions to the author: [email protected]


Table 24-3. A message split into blocks, with each block’s integer.
Message Block Integer
1 st Block
(128 characters)


Alan Mathison Turing
was a British
mathematician,
logician, cryptanalyst,
and computer scientist.
He was highly
influential in t

81546931218178010029845817915569188970228


63503588092404856861189798874246340656702


38839432215827478831941988018897629951268


20043055718365161172430048774726604180301


48768604258244651074200425332013985856895


55969506391783606289711328048889254351125


31133886746309774148590001157056903849858


716430520524535327809


2 nd Block
(128 characters)


he development of
computer science,
providing a
formalisation of the
concepts of "algorithm"
and "computation" with
the Turing m

76631289268154712859022451851447083030531


65677349319343558638588471345037404319956


45932085093160422349968619052225062492420


68799766044149679741160521638235464390814


93343748091892111084834682008279498952509


54725768834415584340223896902248947030025


14434767442075089828357797890134106785932


701869224970151814504


3 rd Block
(128 characters)


achine. Turing is
widely considered to be
the father of computer
science and artificial
intelligence. During
World War II, Turin

77533874832922662837221187157031815413218


69665618828947923728504232931792998759025


56568632161704130179292825376098664640739


13897327838474709028475738093888688583459


78166272494460147358283858671447396525449


89137517820478280435270940014295674175014


93130489686652467441331220556610652015232


230994266943673361249


4 th Block
(107 characters)


g worked for the
Government Code and
Cypher School (GCCS)
at Bletchley Park,
Britain's codebreaking
centre.

87080208891262703930798322686594857958157


73519113112470129994578811890430257029137


88108716196921960428416274796671334547332


64625727703476738415017881880631980435061


77034123161704448596151119133333044771426


77343891157354079822547964726407323487308


38206586983


Converting Strings to Blocks with getBlocksFromText()


rsaCipher.py


  1. def getBlocksFromText(message, blockSize=DEFAULT_BLOCK_SIZE):


  2. Converts a string message to a list of block integers. Each integer




  3. represents 128 (or whatever blockSize is set to) string characters.




The getBlocksFromText() function takes the message and returns a list of blocks (that is, a
list of very large integer values) that represents the message. It is trivially easy to convert between

Free download pdf