Skip to content

Instantly share code, notes, and snippets.

@saturngod
Last active April 6, 2018 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saturngod/89d79651451f72f0a61e0e1996cca38b to your computer and use it in GitHub Desktop.
Save saturngod/89d79651451f72f0a61e0e1996cca38b to your computer and use it in GitHub Desktop.
bin2hex and hex2bin
//bin2hex and hex2bin with Kotlin
import javax.xml.bind.DatatypeConverter
fun bin2hex(byteArray: ByteArray): String {
return DatatypeConverter.printHexBinary(byteArray);
}
fun hex2bin(binary: String): ByteArray {
return DatatypeConverter.parseHexBinary(binary)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment