Skip to content

prongbang/local_auth_crypto

Repository files navigation

local_auth_crypto

pub package

Android and iOS devices to allow Local Authentication + Cryptography via Biometric.

Screenshot

Features

New instance

final localAuthCrypto = LocalAuthCrypto.instance;

Encrypt

await localAuthCrypto.encrypt(message);

PromptInfo

BiometricPromptInfo(
  title: 'BIOMETRIC',
  subtitle: 'Please scan biometric to decrypt',
  negativeButton: 'CANCEL',
);

Decrypt

await localAuthCrypto.authenticate(promptInfo, cipherText);

Getting started

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"

Usage

Flutter

  • 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);

Android

  • 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" />

iOS

  • Add privacy in info.plist file
<dict>
  <key>NSFaceIDUsageDescription</key>
  <string>This application wants to access your TouchID or FaceID</string>
</dict>