mirror of
https://github.com/moparisthebest/keepass2android
synced 2025-02-14 05:50:32 -05:00
simplify Decryption interface
This commit is contained in:
parent
6c8afec8b5
commit
9990ceeb8d
@ -218,6 +218,7 @@ namespace keepass2android
|
|||||||
|
|
||||||
public class FingerprintDecryption : FingerprintCrypt
|
public class FingerprintDecryption : FingerprintCrypt
|
||||||
{
|
{
|
||||||
|
private readonly Context _context;
|
||||||
private readonly byte[] _iv;
|
private readonly byte[] _iv;
|
||||||
|
|
||||||
|
|
||||||
@ -229,6 +230,7 @@ namespace keepass2android
|
|||||||
public FingerprintDecryption(FingerprintModule fingerprint, string keyId, Context context, string prefKey)
|
public FingerprintDecryption(FingerprintModule fingerprint, string keyId, Context context, string prefKey)
|
||||||
: base(fingerprint, keyId)
|
: base(fingerprint, keyId)
|
||||||
{
|
{
|
||||||
|
_context = context;
|
||||||
_iv = Base64.Decode(PreferenceManager.GetDefaultSharedPreferences(context).GetString(GetIvPrefKey(prefKey), null), 0);
|
_iv = Base64.Decode(PreferenceManager.GetDefaultSharedPreferences(context).GetString(GetIvPrefKey(prefKey), null), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,11 +284,9 @@ namespace keepass2android
|
|||||||
return System.Text.Encoding.UTF8.GetString(_cipher.DoFinal(encryptedBytes));
|
return System.Text.Encoding.UTF8.GetString(_cipher.DoFinal(encryptedBytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string DecryptStored(string prefKey, Context context)
|
public string DecryptStored(string prefKey)
|
||||||
{
|
{
|
||||||
string enc = PreferenceManager.GetDefaultSharedPreferences(context).GetString(prefKey, null);
|
string enc = PreferenceManager.GetDefaultSharedPreferences(_context).GetString(prefKey, null);
|
||||||
|
|
||||||
Toast.MakeText(context, "len="+Base64.Decode(enc, 0).Length.ToString(), ToastLength.Long).Show();
|
|
||||||
return Decrypt(enc);
|
return Decrypt(enc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ namespace FingerprintTest
|
|||||||
public override void OnAuthenticationSucceeded(FingerprintManager.AuthenticationResult result)
|
public override void OnAuthenticationSucceeded(FingerprintManager.AuthenticationResult result)
|
||||||
{
|
{
|
||||||
var prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
|
var prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
|
||||||
Toast.MakeText(_context, _fingerprintDec.DecryptStored(_prefKey, _context), ToastLength.Long).Show();
|
Toast.MakeText(_context, _fingerprintDec.DecryptStored(_prefKey), ToastLength.Long).Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user