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

Remove non-visible characters from key, that was read from file #160

Open
taras-mrtn opened this issue Mar 15, 2021 · 2 comments
Open

Remove non-visible characters from key, that was read from file #160

taras-mrtn opened this issue Mar 15, 2021 · 2 comments

Comments

@taras-mrtn
Copy link

There is an issue when a key file was generated by some tools or scripts, and some non-visible characters were inserted. This can be New line or Carriage return symbols, for example. It will be useful to filter such things since even not all text-editors can show that. I had an issue, when echo command inserted 0A byte at the end of the line.

To fix it, something like like this
$string = preg_replace('/[\x00-\x1F\x7F]/u', '', $string);

should be inserted here
https://github.com/paragonie/halite/blob/master/src/KeyFactory.php#L819

@sstok
Copy link

sstok commented Mar 26, 2021

You shouldn't use anything else but the provided KeyFactory to generate a key file, this ensures the key-file Hex encoded.

Using anything else doesn't guarantee that Halite is able to process the key-file.

@taras-mrtn
Copy link
Author

taras-mrtn commented Mar 26, 2021 via email

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

No branches or pull requests

3 participants