I made a node server where i get the encrypted token for my map services, in my flutter app i decrypt it .
The thing is i wanted to protect my token from beeing to obvious inside the code but now the key is also exposed,so what i can do ?
Many guys say about flutter_secure_storage and .env but are they really secure on client side?
Here is my code :
Future<String> decryptMessage(String token) async {
try {
token = token.replaceAll('"', '');
print('Encrypted token from decryptMessage function: $token');
//Key
var iv = encrypt.IV.fromUtf8('ASDFGHJKLASDFGHJ');
var key = encrypt.Key.fromUtf8('ASDFGHJKLASDFGHJ');
final encrypter = encrypt.Encrypter(encrypt.AES(
key,
mode: encrypt.AESMode.cbc,
padding: null,
));
// Decrypt
var encryptedToken = encrypt.Encrypted.fromBase64(token);
final decryptedToken = encrypter.decrypt(encryptedToken, iv: iv);
print(decryptedToken);
return decryptedToken;
} catch (error) {
throw Exception('Error occurred: $error');
}
}