반응형
private val hexArray = "0123456789ABCDEF".toCharArray()
fun bytesToHex(bytes: ByteArray): String {
val hexChars = CharArray(bytes.size * 2)
for (j in bytes.indices) {
val v = (bytes[j] and 0xFF.toByte()).toInt()
hexChars[j * 2] = hexArray[v ushr 4]
hexChars[j * 2 + 1] = hexArray[v and 0x0F]
}
return String(hexChars)
}
fun main(args: Array<String>) {
val bytes = byteArrayOf(10, 2, 15, 11)
val s = bytesToHex(bytes)
println(s)
}
반응형
'개발 > Android' 카테고리의 다른 글
Webview에서 새로운창 출력 (0) | 2020.07.11 |
---|---|
Could not find com.android.tools.build:aapt2:4.0.0-6051327. (0) | 2020.07.11 |
Android API Level 및 명칭 (0) | 2020.07.11 |
ERROR: Could not get unknown property 'com' for root project 'myApp' of type org.gradle.api.Project (0) | 2020.07.11 |
error: cannot find symbol this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); (0) | 2020.07.11 |