前言
OpenHarmony 开发 ets Uint8Array 转 Hex 字符串。
实现
static byteToHexString(byteArray: Uint8Array): string {
let str: string = ""
for (let i = 0; i < byteArray.length; i++) {
let tmp: string = ""
let num: number = byteArray[i]
tmp = num.toString(16)
if (tmp.length == 1) {
tmp = "0" + tmp
}
str += tmp
}
return str
}