Wifi key automatic change

Just installed diet pi on the raspberry pi 4 model b 4 gb on a sandisk 32 gb A1
Flashed the arm v8 64 bit version
Right after, plugged everything and set up done with monitor keyboard
Only installed vim and openssh
Wifi has to be manually connected everytime at login to an account (whenever I switch between root and dietpi)
At every boot, I have to manually reconnect it

Investigation:
Checked wpa_supplicant.conf once configured via dietpi-config, my key shows up as I entered it through dietpi-config. I am online and everything works. Next I logout and log back in, wifi not connected and wpa supplicant config shows a very long hexadecimal string instead of what I wrote for the key. Same with diet-pi config under network configuration tab where my ssid and key are shown side by side ( and a very long hexadecimal string appears instead of the key for my wifi) . Therfore my wifi does not connect and I have to delete the config and reconfigure in dietpi config.

How do I make my wifi configuration persistent and not turn into the very long hexadecimal string at login

Thank you

@MichaIng could you have a look pls?

The key is stored as 64-bit hexadecimal value, as returned when you do:

wpa_passphrase 'yourSSID' 'yourKEY'

This generally works.

wpa_supplicant.conf should show this already before you login/logout. The script applies the entered key as hex value directly, while logout/login has no mechanism to touch the file :thinking:. Logout and login shouldn’t have any effect on the network at all.

After a reflash of the sd card, following the exact same procedures as I did at first, it worked this time. I can logout and login with wifi still connected. Although, on this reflash it occured again at first but when I shut it down and powered the pi back on, the problem disappeared.

Thank you for the help though

hmm maybe there was some corruption on disk preventing the file being saved correctly down to disk? Anyway good it has been solved.