I am trying to write a program to do the hill cipher technique of encryption.
I am stuck trying to break the large array of numbers representing letters etc. into multiple smaller arrays with one column and two rows
does anyone know how this could be done??
Here is the relevant part of my code
from __future__ import division
from pylab import *
# Converts an array of integers into alphabetical characters.
# Input: Array of integers mod 28.
# Output: A section of text of any length, composed only of
# lower case letters, spaces or full stops.
# Array can be of any length, but all entries must be
# integers in the range 0 to 27.
def intArrayToText(intArray):
alpha = 'abcdefghijklmnopqrstuvwxyz .'
toChar = dict([(i , alpha) for i in range(len(alpha))])
chars = map(lambda i: toChar, intArray)
text = ''.join(chars)
return text
# Converts a section of text into an array of integers.
# Input: Prompts the user to enter some text at run-time.
# Assumes the text is all on one line, and composed only of
# lower case letters spaces or full stops.
# Output: Array of integers modulo 28.
def inputTextToIntArray():
alpha = 'abcdefghijklmnopqrstuvwxyz .'
toInt = dict([(alpha, i) for i in range(len(alpha))])
text = raw_input("=> ")
textInts = map(lambda c: toInt[c], text)
intArray = array(textInts)
return intArray
print "Please enter some text"
msg = inputTextToIntArray()
print #a blank line
text = intArrayToText(msg)
print "Your text converted to integers in array is: ", msg
#separating msg into smaller fragments
for i in msg:
block = array([[i],[i]])
print i
print block
It seems that the indenting doesnt come up, im sure you know where to put appropriate indents