您应该使用以下步骤:
在 AES Encrpytion 中存储密码 -> 在您的应用程序中,检索密码并解密 -> 识别面部 -> 打开网站 -> 然后输入用户名和解密密码 -> 登录 -> 其他东西..
您可以使用此 AES 模块进行加密和解密:
Imports System.Collections.Generic
Imports System.IO
Imports System.Linq
Imports System.Security.Cryptography
Imports System.Text
Imports System.Threading.Tasks
Public Module AES
Public Function AES_Encrypt(bytesToBeEncrypted As Byte(), passwordBytes As Byte()) As Byte()
Dim encryptedBytes As Byte() = Nothing
' Set your salt here, change it to meet your flavor:
' The salt bytes must be at least 8 bytes.
Dim saltBytes As Byte() = New Byte() {1, 2, 3, 4, 5, 6, _
7, 8}
Using ms As New MemoryStream()
Using AES As New RijndaelManaged()
AES.KeySize = 256
AES.BlockSize = 128
Dim key = New Rfc2898DeriveBytes(passwordBytes, saltBytes, 1000)
AES.Key = key.GetBytes(AES.KeySize / 8)
AES.IV = key.GetBytes(AES.BlockSize / 8)
AES.Mode = CipherMode.CBC
Using cs = New CryptoStream(ms, AES.CreateEncryptor(), CryptoStreamMode.Write)
cs.Write(bytesToBeEncrypted, 0, bytesToBeEncrypted.Length)
cs.Close()
End Using
encryptedBytes = ms.ToArray()
End Using
End Using
Return encryptedBytes
End Function
Public Function AES_Decrypt(bytesToBeDecrypted As Byte(), passwordBytes As Byte()) As Byte()
Dim decryptedBytes As Byte() = Nothing
' Set your salt here, change it to meet your flavor:
' The salt bytes must be at least 8 bytes.
Dim saltBytes As Byte() = New Byte() {1, 2, 3, 4, 5, 6, _
7, 8}
Using ms As New MemoryStream()
Using AES As New RijndaelManaged()
AES.KeySize = 256
AES.BlockSize = 128
Dim key = New Rfc2898DeriveBytes(passwordBytes, saltBytes, 1000)
AES.Key = key.GetBytes(AES.KeySize / 8)
AES.IV = key.GetBytes(AES.BlockSize / 8)
AES.Mode = CipherMode.CBC
Using cs = New CryptoStream(ms, AES.CreateDecryptor(), CryptoStreamMode.Write)
cs.Write(bytesToBeDecrypted, 0, bytesToBeDecrypted.Length)
cs.Close()
End Using
decryptedBytes = ms.ToArray()
End Using
End Using
Return decryptedBytes
End Function
End Module
请注意,这些函数将字节数组作为其参数并返回字节数组。您可以使用System.Text.Encoding.UTF8.GetBytes("string") 从字符串中获取字节数组,使用System.Text.Encoding.UTF8.GetString(bytes) 从字节数组中获取字符串。如有必要,您可以更改UTF8。