【发布时间】:2021-06-11 10:07:18
【问题描述】:
我正在尝试将 String 转换为 ByteArray,并在 Kotlin 中将 ByteArray 转换为 String。
我的程序崩溃了,所以我决定调试一下,令我惊讶的是,当我将 String 转换为 ByteArray 并将相同的 ByteArray 转换为 String 时,值不一样。
如果我这样做:
val ivEnc = "[B@9a7d34b"
val dataEnc = "[B@1125ac5"
passTextEncrypted.setText(ivEnc.toByteArray().toString())
passTextDecrypted.setText(dataEnc.toByteArray().toString())
我希望收到“[B@9a7d34b”和“[B@1125ac5”。但是每次运行程序时,我都会收到不同的“随机”值(都以“[B@”开头)。
是不是我做错了什么?
【问题讨论】:
标签: android arrays string android-studio kotlin