Created
November 30, 2018 00:27
-
-
Save loganlinn/d9028a7a2040f2f89febd09d5b91f80c to your computer and use it in GitHub Desktop.
Kotlin extension function to convert UUID to ByteArray
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
import java.nio.ByteBuffer | |
import java.util.UUID | |
fun UUID.asBytes(): ByteArray { | |
val b = ByteBuffer.wrap(ByteArray(16)) | |
b.putLong(mostSignificantBits) | |
b.putLong(leastSignificantBits) | |
return b.array() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment