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

Provide competitive .NET Core implementation #1

Merged
merged 2 commits into from Mar 16, 2019
Merged

Provide competitive .NET Core implementation #1

merged 2 commits into from Mar 16, 2019

Conversation

@tkp1n
Copy link
Contributor

@tkp1n tkp1n commented Mar 13, 2019

So I stumbled over your repository and the original challenge from Trustpilot. I really like your approach to the challenge!
I do however propose a more competitive implementation in this PR.

Changes include:

  • Avoid the use of allocation heavy Streams and strings on the hot path of the Main method and allow the re-use of a single plaintext buffer
  • Avoid the encoding of every decrypted ciphertext by searching for the ASCII values of "trust" in the plaintext buffer
  • Only encode the plaintext buffer, once a possible solution was found

I'll let you discover the performance difference yourself :)

tkp1n added 2 commits Mar 13, 2019
* Avoid the use of Streams on the hot path of the Main mehtod and allow the re-use of a single plaintext buffer
* Avoid the encoding of every decrypted ciphertext by searching for the ASCII values of "trust" in the plaintext buffer
* Only encode the plaintext buffer, once a possible solution was found
@ronnieholm ronnieholm merged commit 160505b into ronnieholm:master Mar 16, 2019
@ronnieholm
Copy link
Owner

@ronnieholm ronnieholm commented Mar 16, 2019

Thanks. That's an impressive speedup. I read your post (https://ndportmann.com/improving-dotnet-crypto-code) as well.

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

Successfully merging this pull request may close these issues.

None yet

2 participants