uccjshrimpton

Rail Fence Encryption

Jul 5th, 2016
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. def Rail_Fence_Encryption():
  2.     Plain_Text = input("Please enter some plain text\n-->")
  3.  
  4.     while len(Plain_Text) % 12 != 0:
  5.         Plain_Text += "X"
  6.  
  7.     Cipher_Text = []
  8.     Index_Pattern = [[0,6],[1,5,7,11],[2,4,8,10],[3,9]]
  9.     Index_Pattern_Original_Length = [2,4,4,2]
  10.  
  11.     for Iteration in range(1,round(len(Plain_Text)/12)):
  12.         for Index, List in enumerate(Index_Pattern):
  13.             for Entry in range(Index_Pattern_Original_Length[Index]):
  14.                 List.append(List[Entry]+(12*Iteration))
  15.  
  16.     for Line in Index_Pattern:
  17.         for Index_Value in Line:
  18.             Cipher_Text.append(Plain_Text[Index_Value])
  19.  
  20.     print("".join(Cipher_Text))
  21.  
  22.     """
  23.    The following text:
  24.    hello hello hello there there thereX
  25.  
  26.    Mapped like this:
  27.    h/////h/////h/////t/////t/////t/////
  28.    /e/// /e/// /e/// /h/// /h/// /h///X
  29.    //l/o///l/o///l/o///e/e///e/e///e/e
  30.    ///l/////l/////l/////r/////r/////r
  31.  
  32.    Produces this:
  33.    hhhttte e e h h hXlololoeeeeeelllrrr
  34.    """
  35.    
  36. Rail_Fence_Encryption()
Advertisement
Add Comment
Please, Sign In to add comment