// Algorithm ID AlgorithmId algId = new AlgorithmId(AlgorithmId.get(sigAlg).getOID()); info.set(X509CertInfo.ALGORITHM_ID, new CertificateAlgorithmId(algId));
public static void main(String[] args) throws Exception KeyPair kp = generate("secp256r1"); System.out.println("EC Public (Base64): " + java.util.Base64.getEncoder().encodeToString(kp.getPublic().getEncoded())); keygen intellij
| Scenario | Algorithm | Typical key sizes | When to use | |----------|-----------|-------------------|-------------| | (asymmetric, encryption & signatures) | RSA | 2048 bits (minimum), 3072 bits, 4096 bits | General‑purpose public‑key encryption or signing | | ECDSA (asymmetric, signatures) | EC (named curves) | secp256r1 (aka P‑256 ), secp384r1 ( P‑384 ) | Smaller keys, same security as RSA‑3072, faster | | AES (symmetric, encryption) | AES | 128, 192, 256 bits | Bulk data encryption, symmetric key exchange | same security as RSA‑3072
import java.security.*; import java.security.cert.*; import java.util.Date; import javax.security.auth.x500.X500Principal; import sun.security.x509.*; faster | | AES (symmetric