Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: Rail Fence should remove padding in decode #1069

Closed
maqifrnswa opened this issue Jul 15, 2020 · 2 comments
Closed

Bug report: Rail Fence should remove padding in decode #1069

maqifrnswa opened this issue Jul 15, 2020 · 2 comments
Labels

Comments

@maqifrnswa
Copy link
Contributor

Describe the bug
From #948 (comment)
when decoding with rail fence, padding during decoding operation should be dropped.

To Reproduce

  1. https://gchq.github.io/CyberChef/#recipe=Rail_Fence_Cipher_Encode(7,0)Rail_Fence_Cipher_Decode(7,0)&input=V0FGRkxFUzEyMw

Expected behaviour
Symmetric encoding and decoding should return the same string. It works on other sites, just not cyberchef.

Debugging/How to fix
https://github.com/Flavsditz/CyberChef/blob/master/src/core/operations/RailFenceCipherDecode.mjs#L46

The problem comes when the cipher is padded with spaces. The decode algorithm then places the pads into the decoded text. The easiest way to fix this may be to make the pad symbols some escaped flag character that is removed later (like \n used in the example at https://www.geeksforgeeks.org/rail-fence-cipher-encryption-decryption). It can be done arithmetically, but I think it might get too complicated.

Desktop (if relevant, please complete the following information):

  • CyberChef version: 9.21.0
@maqifrnswa maqifrnswa added the bug label Jul 15, 2020
@maqifrnswa
Copy link
Contributor Author

on closer examination, just removing the padding works. The algorithm doesn't need padding to decode! I'll make a pull request later

@Bihotz
Copy link

Bihotz commented Mar 24, 2021

Nice work catching this. And go Enlightened!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants