-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
566badb
commit 08cd3a5
Showing
8 changed files
with
82 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.davidkhala; | ||
|
||
public class Hex { | ||
public static String encode(byte[] bytes) { | ||
return new String(org.spongycastle.util.encoders.Hex.encode(bytes)); | ||
} | ||
|
||
public static String decode(String string) { | ||
return new String(org.spongycastle.util.encoders.Hex.decode(string)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import org.davidkhala.Hash; | ||
import org.davidkhala.Hex; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.security.NoSuchAlgorithmException; | ||
|
||
public class HashTest { | ||
@Test | ||
public void testMD5() throws NoSuchAlgorithmException { | ||
String message = "p4ssw0rd"; | ||
assert Hex.encode(Hash.MD5(message.getBytes())).equals("2a9d119df47ff993b662a8ef36f9ea20"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import org.davidkhala.KeyStoreTool; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.security.KeyStore; | ||
import java.security.KeyStoreException; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.UnrecoverableEntryException; | ||
import java.security.cert.CertificateException; | ||
|
||
public class KeyStoreTest { | ||
@Test | ||
protected void sanCheck() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableEntryException { | ||
|
||
String type = KeyStore.getDefaultType(); | ||
assert type.equals("pkcs12"); | ||
KeyStore keystore = KeyStore.getInstance(type); | ||
String password = "password"; | ||
keystore.load(null, password.toCharArray()); | ||
KeyStoreTool keyStoreTool = new KeyStoreTool(keystore); | ||
System.out.println(keyStoreTool.aliases()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters