Skip to content

Commit

Permalink
fix printing and digest logic errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aburgd committed Jul 24, 2017
1 parent f22e8ea commit e584657
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/DHKEBI_J.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import java.math.BigInteger;
import java.util.Scanner;
import org.apache.commons.codec.binary.Hex;

public class DHKEBI_J {

Expand All @@ -14,23 +15,25 @@ public static void main(String[] args) {
switch (answer) {
case 1: {
BigInteger userPublicKey = Generation.publicKeyGeneration();
String userKeyDigest = DigestTools.getDigest
(userPublicKey, "SHA").toString();

System.out.printf("Your public key is:\n%d",
byte[] userKeyDigest = DigestTools.getDigest
(userPublicKey, "SHA");
String userKeyHex = Hex.encodeHexString(userKeyDigest);
System.out.printf("Your public key is:\n%d\n",
userPublicKey);
System.out.print("Your public key's digest is:\n");
DigestTools.digestPrinter(userKeyDigest);
DigestTools.digestPrinter(userKeyHex);
break;
}
case 2: {
BigInteger userSharedSecret = Generation.sharedSecretGeneration();
String userSecretDigest = DigestTools.getDigest
(userSharedSecret, "SHA").toString();
System.out.printf("Your shared secret is:\n%d",
byte[] userSecretDigest = DigestTools.getDigest
(userSharedSecret, "SHA");
String userSecretHex = Hex.encodeHexString
(userSecretDigest);
System.out.printf("Your shared secret is:\n%d\n",
userSharedSecret);
System.out.print("Your shared secret's digest is:\n");
DigestTools.digestPrinter(userSecretDigest);
DigestTools.digestPrinter(userSecretHex);
break;
}
default: System.out.print("INVALID_ANS: Please enter 1 or " +
Expand Down

0 comments on commit e584657

Please sign in to comment.