Last active
April 6, 2018 06:18
-
-
Save saturngod/89d79651451f72f0a61e0e1996cca38b to your computer and use it in GitHub Desktop.
bin2hex and hex2bin
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
//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