mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: extract EditBase64Preference from EditChannelDialog
closes #944
This commit is contained in:
parent
d387c7bd04
commit
fa85955e85
4 changed files with 128 additions and 72 deletions
|
|
@ -6,6 +6,7 @@ import com.geeksville.mesh.ConfigKt.loRaConfig
|
|||
import com.geeksville.mesh.ConfigProtos
|
||||
import com.geeksville.mesh.channelSettings
|
||||
import com.google.protobuf.ByteString
|
||||
import java.security.SecureRandom
|
||||
|
||||
/** Utility function to make it easy to declare byte arrays - FIXME move someplace better */
|
||||
fun byteArrayOfInts(vararg ints: Int) = ByteArray(ints.size) { pos -> ints[pos].toByte() }
|
||||
|
|
@ -37,6 +38,13 @@ data class Channel(
|
|||
txEnabled = true
|
||||
}
|
||||
)
|
||||
|
||||
fun getRandomKey(size: Int = 32): ByteString {
|
||||
val bytes = ByteArray(size)
|
||||
val random = SecureRandom()
|
||||
random.nextBytes(bytes)
|
||||
return ByteString.copyFrom(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the name of our channel as a human readable string. If empty string, assume "Default" per mesh.proto spec
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue