如何解决将指纹读取为颤振中的字符串
我有一个在 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 举报,一经查实,本站将立刻删除。