cryptoHome Transposition/Block Cipher

Background

This cipher seeks to mix up the clear text by initially dividing it up into blocks of characters (key long), stacking these blocks and then reading the cipher text down columns to obscure the meaning.

Code

Let's try it out:

Key:
Message:


Algorithm

BEGIN
  INPUT message
  FOR each character in message
     IF character is space
        character = '-'
     ENDIF
  ENDFOR

  INPUT key

  WHILE length(message) mod key != 0
     message = message + '-'

  INPUT conversiontype

  IF conversiontype = 'encrypt'
     INIT result = ''
     grid = message split into key sized substrings
     FOR col = 0 to key-1
        FOR row = 0 to count(grid elements) - 1
           result = result + grid[row][col]
        ENDFOR
     ENDFOR   
  	 OUTPUT result
  ELSEIF conversiontype = 'decrypt'
     INIT result = ''
     grid = message split into (length(message)/key) sized substrings
     FOR col = 0 to length(message) div key - 1
        FOR row = 0 to count(grid elements) - 1
           result = result + grid[col][row]
        ENDFOR
     ENDFOR   
  	 OUTPUT result

  ENDIF
END