왜이 암호 해독 코드가 일부 키와 작동하지 않습니까? 나는 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 당신이 얻고 자하는 것이 무엇이고 대신 무엇을 얻는가? 코드가 어떻게 작동해야하는지 설명 할 수 있습니까? –