Advertisement
tadejpetric

hill decode

Jan 28th, 2018
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. import numpy as np
  2.  
  3. znaki = {'a':0, 'b':1, 'c':2, 'č':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8, 'i':9, 'j':10, 'k':11, 'l':12, 'm':13, 'n':14, 'o':15, 'p':16, 'q':17, 'r':18, 's':19, 'š':20, 't':21, 'u':22, 'v':23, 'w':24, 'x':25, 'y':26, 'z':27, 'ž':28, 'A':29, 'B':30, 'C':31, 'Č':32, 'D':33, 'E':34, 'F':35, 'G':36, 'H':37, 'I':38, 'J':39, 'K':40, 'L':41, 'M':42, 'N':43, 'O':44, 'P':45, 'Q':46, 'R':47, 'S':48, 'Š':49, 'T':50, 'U':51, 'V':52, 'W':53, 'X':54, 'Y':55, 'Z':56, 'Ž':57, '.':58, ',':59, '-':60}
  4. #                                                                                                
  5. message = "Y-TČtNž,of-mQUWMA-FINf-mEtRrJjLIWušvzQš.X-č-gnnsIGPžkOuuzNmFf-mNYQcxatsuGGLzjNhkiEfvuLlDZtuBršb-ČrQHunpvqQgPOJ.bbaYč.vMrxgčf-mOcJQpDlGaoS,KElš-aIšpkatOšžOLZrkwuuzNmFf-m-TrzFAwBžVŠV"
  6. inverse = np.array( [ [58, 1, 2], [59, 1, 1], [6, 59, 58] ] )
  7.  
  8. arr = np.zeros((3,60))
  9. for i in range (60):
  10.     for j in range(3):
  11.         arr[j][i] = znaki[ message[i*3+j] ]
  12. arr = np.dot(inverse, arr)
  13.  
  14. for i in range (60):
  15.     for j in range(3):
  16.         arr[j][i] = int(arr[j][i])%61
  17.  
  18. znaki = { v: k for k,v in znaki.items()}
  19.  
  20. string = ""
  21. for i in range (60):
  22.     for j in range(3):
  23.         string += znaki[ arr[j][i] ]
  24.  
  25. print (string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement