我想用6位数字的密码锁定我的应用程序.当用户创建新的PIN时,该PIN的散列被保存在Ffltter安全存储中.通过从安全存储中获取散列的PIN并将它们进行比较来验证PIN.这会安全吗?
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:steel_crypt/steel_crypt.dart';
//Saves the hash of the pin in FlutterSecureStorage
Future<void> createPin(String pin) async {
const secureStorage = FlutterSecureStorage();
//Hash the pin and save the hash
var hasher = HashCrypt(algo: Hash算法.Sha_256);
String hashedPin = hasher.hash(inp: pin);
await secureStorage.write(key: "hashedPin", value: hashedPin)
return;
}
//Check if the given pin is correct
Future<bool> checkPin(String pin) async {
const secureStorage = FlutterSecureStorage();
var hashedPin = await secureStorage.read(key: "hashedPin")
var hasher = HashCrypt(algo: Hash算法.Sha_256);
return hasher.check(plain: pin, hashed: hashedPin);
}