add secure methods (#44)
This commit is contained in:
parent
195d2f16c9
commit
7c73d2418c
|
|
@ -8,4 +8,12 @@ object ByteUtils {
|
|||
}
|
||||
}
|
||||
|
||||
fun decodeHex(hex: String): ByteArray {
|
||||
check(hex.length % 2 == 0) { "Must have an even length" }
|
||||
|
||||
return hex.chunked(2)
|
||||
.map { it.toInt(16).toByte() }
|
||||
.toByteArray()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,4 +24,6 @@ object SecureRandomStringGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
fun generateRandomBytes(size: Int) = ByteArray(size).also(SecureRandom()::nextBytes)
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue