nabarun1011

Test

Aug 26th, 2016
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. def transencrypt(word,key):
  2.     count1=0
  3.     count2=0
  4.     encrypted=''
  5.     encryptbox=['']*key
  6.     while count1<key:
  7.         count2=count1
  8.         while count2<len(word):
  9.             encryptbox[count1]+=word[count2]
  10.             count2+=key
  11.         encrypted+=encryptbox[count1]
  12.         count1+=1
  13.     return encrypted
  14.  
  15. def transdecrypt(word,key):
  16.     import math
  17.     count1=0
  18.     count2=0
  19.     decrypted=''
  20.     col=int(math.ceil(len(word)/key))
  21.     decryptbox=['']*col
  22.     while count1<col:
  23.         count2=count1
  24.         while count2<len(word):
  25.             decryptbox[count1]+=word[count2]
  26.             count2+=col
  27.         decrypted+=decryptbox[count1]
  28.         count1+=1
  29.     return decrypted
  30.  
  31. print(transencrypt('hello world',5))
  32. print(transdecrypt('h dewlolrol',5))
Add Comment
Please, Sign In to add comment