This repository was archived by the owner on Dec 24, 2025. It is now read-only.
Use SHA256 bytes without translating to string#60
Open
DawnStream wants to merge 1 commit intoklaxit:masterfrom
Open
Use SHA256 bytes without translating to string#60DawnStream wants to merge 1 commit intoklaxit:masterfrom
DawnStream wants to merge 1 commit intoklaxit:masterfrom
Conversation
Ben-J (ben-j69)
suggested changes
Jul 12, 2022
Contributor
Ben-J (ben-j69)
left a comment
There was a problem hiding this comment.
Thanks for the work, there are minor adjustments in code to do.
I am currently testing it and will give you a feedback later.
Breaking changes are involved so what remains to do ( I can do it on another PR):
- bump to v3.0 with a breaking change warning in changelog
- move com.gradle.plugin-publish to 1.0.0
- move kotest to 5.3.1
| @@ -26,20 +26,19 @@ object Utils { | |||
| * Encode string to sha256 | |||
Contributor
There was a problem hiding this comment.
Can you please complete the comment and explain a bit more ?
| */ | ||
| class UtilsTest : WordSpec({ | ||
|
|
||
| fun byteArrayOfInts(vararg ints: Int) = ByteArray(ints.size) { pos -> ints[pos].toByte() } |
Contributor
There was a problem hiding this comment.
Please add a comment. Can it be private ?
| key, | ||
| packageName | ||
| ) shouldBe "{ 0x5b, 0x6, 0x18, 0x31, 0xb, 0x72, 0x57, 0x5, 0x5d, 0x57, 0x3 }" | ||
| ) shouldBe "{ 0x67, 0xcb, 0xae, 0xcb, 0x4c, 0xbb, 0x42, 0xad, 0x59, 0x19, 0xe2 }" //"{ 0x5b, 0x6, 0x18, 0x31, 0xb, 0x72, 0x57, 0x5, 0x5d, 0x57, 0x3 }" |
Contributor
There was a problem hiding this comment.
Why keep this as a comment ?
| "encode String in sha256" { | ||
| val key = "youCanNotFindMySecret!" | ||
| Utils.sha256(key) shouldBe "7bdc2b5992ef7b4cce0e06295f564f4fad0c96e5f82a0bcf9cd8323d3a3bcfbd" | ||
| Utils.sha256(key) shouldBe byteArrayOfInts( 0x7b, 0xdc, 0x2b, 0x59, 0x92, 0xef, 0x7b, 0x4c, 0xce, 0x0e, 0x06, 0x29, 0x5f, 0x56, 0x4f, 0x4f, 0xad, 0x0c, 0x96, 0xe5, 0xf8, 0x2a, 0x0b, 0xcf, 0x9c, 0xd8, 0x32, 0x3d, 0x3a, 0x3b, 0xcf, 0xbd) /*"7bdc2b5992ef7b4cce0e06295f564f4fad0c96e5f82a0bcf9cd8323d3a3bcfbd"*/ |
Contributor
There was a problem hiding this comment.
Comment on a new line please with a explanation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current implementation translate the bytes into string , which limits the actual bytes used for XOR'ing and misses the high entropy characteristics of the SHA256 function (as the string will only be constructed of 1-0, a-f).
This PR removes the translation to string in both creating the Kotlin code generating the obfuscated key and the C++ code that decode it