File tree Expand file tree Collapse file tree
app/src/main/java/to/bitkit Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package to.bitkit.ext
22
3- import java.security.MessageDigest
43import kotlin.io.encoding.Base64
5- import kotlin.io.encoding.ExperimentalEncodingApi
64
7- // region hex
8- @OptIn(ExperimentalStdlibApi ::class )
95fun ByteArray.toHex (): String = this .toHexString()
106
11- @OptIn(ExperimentalStdlibApi ::class )
127fun String.fromHex (): ByteArray = this .hexToByteArray()
13- // endregion
148
15- @OptIn(ExperimentalEncodingApi ::class )
169fun ByteArray.toBase64 (): String = Base64 .encode(this )
1710
18- @OptIn(ExperimentalEncodingApi ::class )
1911fun String.fromBase64 (): ByteArray = Base64 .decode(this )
2012
2113val String .uByteList get() = this .toByteArray().map { it.toUByte() }
22-
23- fun ByteArray.toSha256 (): ByteArray {
24- val digest = MessageDigest .getInstance(" SHA-256" )
25- return digest.digest(this )
26- }
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import to.bitkit.data.keychain.Keychain
2323import to.bitkit.di.IoDispatcher
2424import to.bitkit.di.json
2525import to.bitkit.env.Env
26+ import to.bitkit.ext.toHex
2627import to.bitkit.utils.AppError
2728import to.bitkit.utils.Crypto
2829import to.bitkit.utils.Logger
@@ -295,10 +296,6 @@ class RNBackupClient @Inject constructor(
295296
296297 return cipher.doFinal(ciphertext + tag)
297298 }
298-
299- private fun ByteArray.toHex (): String {
300- return this .joinToString(" " ) { " %02x" .format(it) }
301- }
302299}
303300
304301@Serializable
You can’t perform that action at this time.
0 commit comments