local_auth_signature 1.0.4 copy "local_auth_signature: ^1.0.4" to clipboard
local_auth_signature: ^1.0.4 copied to clipboard

Generate key pair and signing (NIST P-256 EC key pair using ECDSA) using Local Authentication for Android and iOS.

local_auth_signature #

pub package

Generate key pair and signing (NIST P-256 EC key pair using ECDSA) using Local Authentication for Android and iOS.

Screenshot

Getting started #

It is really easy to use! You should ensure that you add the local_auth_signature as a dependency in your flutter project.

local_auth_signature: "^1.0.4"

Usage #

Flutter #

New instance

final _localAuthSignature = LocalAuthSignature.instance;

Define Key

final _key = 'com.prongbang.signx.key';

Create KeyPair

try {
    final publicKey = await _localAuthSignature.createKeyPair(
        _key,
        AndroidPromptInfo(
            title: 'BIOMETRIC',
            subtitle: 'Please allow biometric',
            negativeButton: 'CANCEL',
        ),
        IOSPromptInfo(reason: 'Please allow biometric'),
    );
    print('publicKey: $publicKey');
} on PlatformException catch (e) {
  print('PlatformException: ${e.code}');
}

Sign

final _payload = 'Hello';
try {
    final signature = await _localAuthSignature.sign(
        _key,
        _payload,
        AndroidPromptInfo(
            title: 'BIOMETRIC',
            subtitle: 'Please allow biometric',
            negativeButton: 'CANCEL',
        ),
        IOSPromptInfo(reason: 'Please allow biometric'),
    );
    print('signature: $signature');
} on PlatformException catch (e) {
  print('PlatformException: ${e.code}');
}

Verify

try {
    final verified = await _localAuthSignature.verify(
        _key,
        _payload,
        _signature!,
        AndroidPromptInfo(
            title: 'BIOMETRIC',
            subtitle: 'Please allow biometric',
            negativeButton: 'CANCEL',
        ),
        IOSPromptInfo(reason: 'Please allow biometric'),
    );
    print('verified: $verified');
} on PlatformException catch (e) {
    print('PlatformException: ${e.code}');
}

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>
3
likes
0
pub points
75%
popularity

Publisher

verified publisherwachasit.com

Generate key pair and signing (NIST P-256 EC key pair using ECDSA) using Local Authentication for Android and iOS.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on local_auth_signature