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
import lombok.*; | |
import java.security.KeyStore; | |
public class KeyTool4J { | |
@Getter private String certificateOwner = "unknown"; | |
@Getter private String organizationalUnit = "unknown"; | |
@Getter private String organizationName = "unknown"; | |
@Getter private String localityName = "unknown"; |
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
import java.security.*; | |
import java.security.spec.X509EncodedKeySpec; | |
import java.util.Base64; | |
import javax.crypto.Cipher; | |
public class E2EE { | |
private KeyPair keyPair; | |
private String publicKey; | |
private String privateKey; |
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
private static String hash(String hashType, String inputHash) throws NoSuchAlgorithmException, IOException { | |
MessageDigest messageDigest = MessageDigest.getInstance(hashType); | |
messageDigest.update(inputHash.getBytes()); | |
byte[] digest = messageDigest.digest(); | |
StringBuffer stringBuffer = new StringBuffer(); | |
for (byte byt : digest) | |
stringBuffer.append(String.format("%02x", byt & 0xff)); | |
return stringBuffer.toString(); | |
} |