このトランスポーズ復号化コードが一部のキーで機能しないのはなぜですか?私は5キーでの「Hello World」を暗号化しようとしているTranspostionの復号化が一部のキーで機能していませんか?
def transencrypt(word,key):
'''Traspositon encryption function. This function is used to encrypt a line
using the transposition encryption method. To know how transpositon encryption
works you can visit here https://en.wikipedia.org/wiki/Transposition_cipher.'''
count1=0
count2=0
encrypted=''
encryptbox=['']*key
while count1<key:
count2=count1
while count2<len(word):
encryptbox[count1]+=word[count2]
count2+=key
encrypted+=encryptbox[count1]
count1+=1
return encrypted
def transdecrypt(word,key):
'''This Function is for the decrypting the encrypted strings encrypted by
transencrypt().This function only requires the encrypted string and the key
with which it has been decrypted.'''
import math
count1=0
count2=0
decrypted=''
col=int(math.ceil(len(word)/key))
decryptbox=['']*col
while count1<col:
count2=count1
while count2<len(word):
decryptbox[count1]+=word[count2]
count2+=col
decrypted+=decryptbox[count1]
count1+=1
return decrypted
print(transencrypt('hello world',5))
print(transdecrypt('h dewlolrol',5))
が、復号時に私が間違った結果を取得しています。他のキーを使用すると正常に動作します。
あなたはここではなく、ペーストビンにあなたのコードを投稿することができますか?読みやすく、コードが常にあなたの質問に関連付けられています。 – MichaelDotKnox
彼らはそれを編集したと思います。あなたは今読むことができますか? – Star
@Starあなたは何を得ることが期待されていますか、代わりに何を得るのですか?あなたのコードがどのように動作するはずですか? –