Skip to content

Commit 123d173

Browse files
committed
refactor: use shared toHex utility
1 parent ce5ce13 commit 123d173

2 files changed

Lines changed: 1 addition & 14 deletions

File tree

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
package to.bitkit.ext
22

3-
import java.security.MessageDigest
43
import kotlin.io.encoding.Base64
54
import kotlin.io.encoding.ExperimentalEncodingApi
65

7-
// region hex
8-
@OptIn(ExperimentalStdlibApi::class)
96
fun ByteArray.toHex(): String = this.toHexString()
107

11-
@OptIn(ExperimentalStdlibApi::class)
128
fun String.fromHex(): ByteArray = this.hexToByteArray()
13-
// endregion
149

1510
@OptIn(ExperimentalEncodingApi::class)
1611
fun ByteArray.toBase64(): String = Base64.encode(this)
@@ -19,8 +14,3 @@ fun ByteArray.toBase64(): String = Base64.encode(this)
1914
fun String.fromBase64(): ByteArray = Base64.decode(this)
2015

2116
val 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-
}

app/src/main/java/to/bitkit/services/RNBackupClient.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import to.bitkit.data.keychain.Keychain
2323
import to.bitkit.di.IoDispatcher
2424
import to.bitkit.di.json
2525
import to.bitkit.env.Env
26+
import to.bitkit.ext.toHex
2627
import to.bitkit.utils.AppError
2728
import to.bitkit.utils.Crypto
2829
import 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

0 commit comments

Comments
 (0)