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

how can I exlude the combination of \n and \r characters in the encrypted result? #8

Closed
Radu3000 opened this issue Apr 9, 2020 · 2 comments

Comments

@Radu3000
Copy link

Radu3000 commented Apr 9, 2020

It is ok if my encrypted result has "]" and "n" separately. But that creates problems during rendering in java and python - new lines and other ...

Can I prevent the encrypted results to produce the following sequence of chars?
"\n" and "\r"

Thanks,
Radu

@emulbreh
Copy link
Owner

There's nothing built into pyffx that would help, but there's probably a way to implement this restriction on top of it.

If you don't need to preserve the length of the output you could try to escape the sequences you don't want (e.g. replace "\n" -> "\n0" and "0" -> "00").

Alternatively, you could also try to come up with a scheme that uses a bigger alphabet, e.g.

safe_chars = set(string.printable)
alphabet = (chars - {'\n'}) | {f'\n{c}' for c in chars - {'\r'}}

If the length of the string is odd you need to treat the last char specially or pad the string.

@emulbreh
Copy link
Owner

emulbreh commented May 7, 2020

I'm closing this issue for now. Feel free to to open a PR if there's something unversally useful you'd like to add to pyffx. Regarding your actual problem, stackoverflow might be a better place to ask for an encoding scheme.

@emulbreh emulbreh closed this as completed May 7, 2020
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

No branches or pull requests

2 participants