I used your code, so I feel the need to show you how I fixed it.
I am making cryptopals to solve this problem in Go.
I will guide you through the error as the code is mostly correct.
for len(plaintext) > 0 { cipher.Decrypt(plaintext, ciphertext) plaintext = plaintext[bs:] ciphertext = ciphertext[bs:] }
The loop decrypts the data, but does not put it anywhere. It simply shifts two arrays without creating an output.
i := 0 plaintext := make([]byte, len(ciphertext)) finalplaintext := make([]byte, len(ciphertext)) for len(ciphertext) > 0 { cipher.Decrypt(plaintext, ciphertext) ciphertext = ciphertext[bs:] decryptedBlock := plaintext[:bs] for index, element := range decryptedBlock { finalplaintext[(i*bs)+index] = element } i++ plaintext = plaintext[bs:] } return finalplaintext[:len(finalplaintext)-5]
What this new enhancement is is to save the decrypted data into a new [] byte called finalplaintext. If you return, you will receive data.
This is important because the Decrypt function only works with one block size at a time.
I am returning the fragment because I suspect that it has been completed. I am new to cryptography. Go so that someone can fix / revise it.
source share