-
Notifications
You must be signed in to change notification settings - Fork 42
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
Use SHA256 bytes without translating to string #60
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ import java.io.File | |
*/ | ||
class UtilsTest : WordSpec({ | ||
|
||
fun byteArrayOfInts(vararg ints: Int) = ByteArray(ints.size) { pos -> ints[pos].toByte() } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment. Can it be private ? |
||
|
||
val packageName = "com.klaxit.test" | ||
|
||
"Using getCppPackageName()" should { | ||
|
@@ -25,7 +27,7 @@ class UtilsTest : WordSpec({ | |
"Using sha256()" should { | ||
"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"*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment on a new line please with a explanation |
||
} | ||
} | ||
|
||
|
@@ -35,14 +37,14 @@ class UtilsTest : WordSpec({ | |
Utils.encodeSecret( | ||
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 }" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why keep this as a comment ? |
||
} | ||
"encode String with special characters" { | ||
val key = "@&é(§èçà)-ù,;:=#°_*%£?./+" | ||
Utils.encodeSecret( | ||
key, | ||
packageName | ||
) shouldBe "{ 0x70, 0x45, 0xa2, 0xcc, 0x4c, 0xf5, 0x9e, 0xa5, 0x9a, 0xf0, 0xc1, 0xa6, 0x92, 0x4a, 0x4e, 0xa6, 0x8a, 0x1a, 0xc, 0x5e, 0x5, 0x14, 0xf7, 0x86, 0x6b, 0x13, 0x40, 0xf5, 0x9a, 0xc, 0x16, 0x16, 0x19 }" | ||
) shouldBe "{ 0x4c, 0x88, 0x14, 0x36, 0xb, 0x3c, 0x8b, 0xd, 0x9e, 0xbe, 0x20, 0x95, 0xe9, 0xce, 0xbe, 0x4a, 0x94, 0xf1, 0xb2, 0x7d, 0x4c, 0x70, 0x51, 0x91, 0x69, 0x98, 0x4d, 0xf7, 0x8a, 0xbc, 0xb1, 0xa2, 0x27 }" | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please complete the comment and explain a bit more ?