Skip to content

fix: XORCipher leaves newline-class characters un-encrypted - #315

Open
dbdefault wants to merge 1 commit into
TheAlgorithms:masterfrom
dbdefault:fix/308/xor-cipher-newline-characters
Open

dbdefault wants to merge 1 commit into
TheAlgorithms:masterfrom
dbdefault:fix/308/xor-cipher-newline-characters

Conversation

@dbdefault

Copy link
Copy Markdown

fix: XORCipher leaves newline-class characters un-encrypted

Replace str.replace(/./g, ...) with Array.from(str, ...) so that
every character including \n, \r, \u2028, \u2029 is XORed with
the key. The dot in regex /./g does not match line terminators without
the dotAll flag.

Add test cases for newline, carriage return, and line separator inputs.

Fixes #308

Replace str.replace(/./g, ...) with Array.from(str, ...) so that
every character including \\n, \\r, \\u2028, \\u2029 is XORed with
the key. The dot in regex /./g does not match line terminators without
the dotAll flag.

Add test cases for newline, carriage return, and line separator inputs.

Fixes TheAlgorithms#308
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ciphers/xor_cipher: XORCipher leaves newline-class characters un-encrypted (regex /./g skips line terminators)

1 participant