From ee1f43d98d7e2265d9c6154ae094098dc169a21f Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 29 Dec 2020 20:43:39 -0800 Subject: #1033: Some devices can't decrypt a password they just made --- app/src/main/java/github/daneren2005/dsub/util/KeyStoreUtil.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/src/main/java/github/daneren2005/dsub/util/KeyStoreUtil.java b/app/src/main/java/github/daneren2005/dsub/util/KeyStoreUtil.java index 057ac833..8ff9ec69 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/KeyStoreUtil.java +++ b/app/src/main/java/github/daneren2005/dsub/util/KeyStoreUtil.java @@ -97,9 +97,14 @@ public class KeyStoreUtil { outputStream.write(cipher.doFinal(plainTextString.getBytes(KEYSTORE_BYTE_ENCODING))); // Encode the return full stream for storage - Log.d(TAG, "Password encryption successful"); - return Base64.encodeToString(outputStream.toByteArray(), Base64.NO_WRAP); + String encryptedPassword = Base64.encodeToString(outputStream.toByteArray(), Base64.NO_WRAP); + if(decrypt((encryptedPassword)) == null) { + Log.e(TAG, "We couldn't decrypt the password we just encypted!"); + return null; + } + Log.d(TAG, "Password encryption successful"); + return encryptedPassword; } catch (Exception e) { Log.w(TAG, "Password encryption failed"); Log.d(TAG, Log.getStackTraceString(e)); -- cgit v1.2.3