Android and iOS devices to allow Local Authentication + Cryptography via Biometric.
final localAuthCrypto = LocalAuthCrypto.instance;
await localAuthCrypto.encrypt(message);
BiometricPromptInfo(
title: 'BIOMETRIC',
subtitle: 'Please scan biometric to decrypt',
negativeButton: 'CANCEL',
);
await localAuthCrypto.authenticate(promptInfo, cipherText);
It is really easy to use! You should ensure that you add the local_auth_crypto
as a dependency in your flutter project.
local_auth_crypto: "^1.1.1"
- Encrypt
final localAuthCrypto = localAuthCrypto.instance;
final message = 'TOKEN';
final cipherText = await localAuthCrypto.encrypt(message);
- Decrypt
final localAuthCrypto = localAuthCrypto.instance;
final promptInfo = BiometricPromptInfo(
title: 'BIOMETRIC',
subtitle: 'Please scan biometric to decrypt',
negativeButton: 'CANCEL',
);
final plainText = await localAuthCrypto.authenticate(promptInfo, cipherText);
- Update code in
MainActivity.kt
file
import io.flutter.embedding.android.FlutterFragmentActivity
class MainActivity : FlutterFragmentActivity()
- Add use-permissions in
AndroidManifest.xml
file
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
- Add privacy in
info.plist
file
<dict>
<key>NSFaceIDUsageDescription</key>
<string>This application wants to access your TouchID or FaceID</string>
</dict>