mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
If user changes back to default channel, use the standard key
This commit is contained in:
parent
aa3a8bf089
commit
6195874982
2 changed files with 18 additions and 1 deletions
|
|
@ -147,12 +147,20 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {
|
|||
newSettings.name = channelNameEdit.text.toString().trim()
|
||||
|
||||
// Generate a new AES256 key (for any channel not named Default)
|
||||
if (newSettings.name != Channel.defaultChannelName) {
|
||||
if (!newSettings.name.equals(
|
||||
Channel.defaultChannelName,
|
||||
ignoreCase = true
|
||||
)
|
||||
) {
|
||||
debug("ASSIGNING NEW AES256 KEY")
|
||||
val random = SecureRandom()
|
||||
val bytes = ByteArray(32)
|
||||
random.nextBytes(bytes)
|
||||
newSettings.psk = ByteString.copyFrom(bytes)
|
||||
} else {
|
||||
debug("ASSIGNING NEW default AES128 KEY")
|
||||
newSettings.name = Channel.defaultChannelName // Fix any case errors
|
||||
newSettings.psk = ByteString.copyFrom(Channel.channelDefaultKey)
|
||||
}
|
||||
|
||||
// Try to change the radio, if it fails, tell the user why and throw away their redits
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue