Skip to content

Instantly share code, notes, and snippets.

@loganlinn
Created November 30, 2018 00:27
Show Gist options
  • Save loganlinn/d9028a7a2040f2f89febd09d5b91f80c to your computer and use it in GitHub Desktop.
Save loganlinn/d9028a7a2040f2f89febd09d5b91f80c to your computer and use it in GitHub Desktop.
Kotlin extension function to convert UUID to ByteArray
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