simplify Decryption interface

This commit is contained in:
Philipp Crocoll 2015-12-30 16:17:55 +01:00
parent 6c8afec8b5
commit 9990ceeb8d
2 changed files with 5 additions and 5 deletions

View File

@ -218,6 +218,7 @@ namespace keepass2android
public class FingerprintDecryption : FingerprintCrypt
{
private readonly Context _context;
private readonly byte[] _iv;
@ -229,6 +230,7 @@ namespace keepass2android
public FingerprintDecryption(FingerprintModule fingerprint, string keyId, Context context, string prefKey)
: base(fingerprint, keyId)
{
_context = context;
_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));
}
public string DecryptStored(string prefKey, Context context)
public string DecryptStored(string prefKey)
{
string enc = PreferenceManager.GetDefaultSharedPreferences(context).GetString(prefKey, null);
Toast.MakeText(context, "len="+Base64.Decode(enc, 0).Length.ToString(), ToastLength.Long).Show();
string enc = PreferenceManager.GetDefaultSharedPreferences(_context).GetString(prefKey, null);
return Decrypt(enc);
}
}

View File

@ -124,7 +124,7 @@ namespace FingerprintTest
public override void OnAuthenticationSucceeded(FingerprintManager.AuthenticationResult result)
{
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();
}
}