Skip to content

Commit

Permalink
Imrpoved isSecret implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jul 19, 2024
1 parent 211765f commit f22e99f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/main/java/crypto/RSAKeyStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,7 @@ public boolean isEncryptedSecret(String input) {
}

private boolean validBase64(String input) {
try {
Base64.decodeBase64(input);
return true;
} catch (IllegalArgumentException e) {
return false;
}
return Base64.decodeBase64(input).length > 0;
}

private String stripPublicKey(String publicKey) {
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/crypto/KeyStoreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ void isEncryptedSecret() {

assertTrue(keyStore.isEncryptedSecret(encryptedSecret));
assertFalse(keyStore.isEncryptedSecret("!"));
assertFalse(keyStore.isEncryptedSecret("!".repeat(342)));
assertFalse(keyStore.isEncryptedSecret("%".repeat(342)));
//Corner case - waiting for a smart tester to pick this up
assertTrue(keyStore.isEncryptedSecret("a".repeat(342)));
}
Expand Down

0 comments on commit f22e99f

Please sign in to comment.