Created
May 5, 2020 15:35
-
-
Save araqnid/d9d444ef28dfab1a40c618a9df598fff to your computer and use it in GitHub Desktop.
using messagedigest from Kotlin
This file contains 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
import java.security.MessageDigest | |
import kotlin.test.Test | |
import kotlin.test.assertTrue | |
class Scratchpad { | |
@Test | |
fun scratchpad() { | |
val digest = MessageDigest.getInstance("SHA-256") | |
digest.update("foo".toByteArray()) | |
digest.update("bar".toByteArray()) | |
val result1 = digest.digest() | |
val digest2 = MessageDigest.getInstance("SHA-256") | |
digest2.update("foobar".toByteArray()) | |
val result2 = digest2.digest() | |
assertTrue(result1 contentEquals result2) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment