问题描述
我有一个在 android 上运行的应用程序,它使用指纹进行身份验证。该应用程序正在运行,它正在返回我想要的东西。但我仍然想读取散列或字符串的指纹,以便我可以为另一个项目散列它。到目前为止我的代码:
main.dart
import 'package:fingerprint/secondpage.dart';
import 'package:Flutter/cupertino.dart';
import 'package:Flutter/material.dart';
import 'package:Flutter/services.dart';
import 'package:local_auth/local_auth.dart';
void main() {
runApp(MaterialApp(
debugShowCheckedModeBanner: false,home: FingerprintApp(),));
}
class FingerprintApp extends StatefulWidget{
@override
_FingerprintAppState createState() => _FingerprintAppState();
}
class _FingerprintAppState extends State<FingerprintApp>{
LocalAuthentication auth = LocalAuthentication();
bool _canCheckBiometric ;
List<BiometricType> _availableBiometrics;
String autherized = "Not autherized";
Future<void> _checkBiometric() async {
bool canCheckBiometric;
try {
canCheckBiometric = await auth.canCheckBiometrics;
} on PlatformException catch (e) {
print(e);
}
if (!mounted) return;
setState(() {
_canCheckBiometric = canCheckBiometric;
});
}
Future<void> _getAvailableBiometric() async {
List<BiometricType> availableBiometric;
try{
availableBiometric = await auth.getAvailableBiometrics();
} on PlatformException catch (e){
print(e);
}
setState(() {
_availableBiometrics = availableBiometric;
});
}
Future<void> _authenticate() async{
bool authenticated = false;
try{
authenticated = await auth.authenticateWithBiometrics(
localizedReason: "Scan your finger to authenticate",useErrorDialogs: true,stickyAuth: false
);
} on PlatformException catch(e){
print(e);
}
if (!mounted) return;
setState(() {
autherized = authenticated ? "Autherized success":"Failed to authenticate";
if(authenticated){
Navigator.push(context,MaterialPageRoute(builder: (context) => SecondPage()));
}
print(autherized);
});
}
@override
void initState(){
_checkBiometric();
_getAvailableBiometric();
}
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
backgroundColor: Color(0xFF07496D),body: Padding(
padding: const EdgeInsets.symmetric(vertical: 12.0,horizontal: 24.0),child: Column(
mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[
Center(
child: Text("Login",style: TextStyle(
color: Colors.white,fontSize: 48.0,fontWeight: FontWeight.bold
),),Container(
margin: EdgeInsets.symmetric(vertical: 50.0),child: Column(
children: <Widget>[
Image.asset(
'assets/fingerprint.png',width: 120.0,Text("Fingerprint Auth",style: TextStyle(
color: Colors.white,fontSize: 22.0,fontWeight: FontWeight.bold,Container(
width: 150.0,margin: EdgeInsets.symmetric(vertical: 15.0),child: Text("Authenticate with your fingerprint instead of your password",textAlign: TextAlign.center,style: TextStyle(
color: Colors.white,height: 1.5,Container(
margin: EdgeInsets.symmetric(vertical: 15.0 ),width: double.infinity,child: RaisedButton(
onpressed: _authenticate,elevation: 0.0,color: Color(0xFF04A5ED),shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),child: Padding(
padding: EdgeInsets.symmetric(vertical:14.0,child: Text("Authenticate",style: TextStyle(
color: Colors.white,)
)
)
]
)
)
],);
}
}
androidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.fingerprint">
<uses-permission android:name="android.permission.USE_FINGERPRINT"></uses-permission>
<application
android:label="fingerprint"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singletop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that,this theme continues
to determine the Window background behind the Flutter UI. -->
<Meta-data
android:name="io.Flutter.embedding.android.normalTheme"
android:resource="@style/normalTheme"
/>
<!-- displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame,then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<Meta-data
android:name="io.Flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the Meta-data below.
This is used by the Flutter tool to generate GeneratedpluginRegistrant.java -->
<Meta-data
android:name="FlutterEmbedding"
android:value="2" />
</application>
</manifest>
pubspec.yaml
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
Flutter:
sdk: Flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
local_auth: ^0.4.0+1
当我运行这个应用程序时,它需要一个指纹并接受我移动到另一个页面。但是有什么方法可以读取 sha256 或 sha1 或字符串中的指纹?我想将此指纹保存在一个文件中以备将来使用。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)