-
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
Showing
9 changed files
with
239 additions
and
373 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,40 @@ | ||
package kotlin | ||
|
||
import org.apache.commons.codec.binary.Hex | ||
|
||
import java.math.BigInteger | ||
import java.util.Scanner | ||
|
||
object DHKEBI { | ||
|
||
private val stdin = Scanner(System.`in`) | ||
|
||
@JvmStatic fun main(args: Array<String>) { | ||
println("Enter an option and press Return/Enter:") | ||
println("1) public key\n2) shared secret") | ||
|
||
val answer = stdin.nextInt() | ||
|
||
when (answer) { | ||
1 -> { | ||
val userPublicKey = Generation.publicKeyGeneration() | ||
val userKeyDigest = DigestTools.getDigest(userPublicKey, "SHA") | ||
val userKeyHex = Hex.encodeHexString(userKeyDigest) | ||
System.out.printf("Your public key is:\n%d\n", | ||
userPublicKey) | ||
print("Your public key's digest is:\n") | ||
DigestTools.digestPrinter(userKeyHex) | ||
} | ||
2 -> { | ||
val userSharedSecret = Generation.sharedSecretGeneration() | ||
val userSecretDigest = DigestTools.getDigest(userSharedSecret, "SHA") | ||
val userSecretHex = Hex.encodeHexString(userSecretDigest) | ||
System.out.printf("Your shared secret is:\n%d\n", | ||
userSharedSecret) | ||
print("Your shared secret's digest is:\n") | ||
DigestTools.digestPrinter(userSecretHex) | ||
} | ||
else -> print("INVALID_ANS: Please enter 1 or " + "2") | ||
} | ||
} | ||
} |
Oops, something went wrong.