使用 openssl (HEX) 生成 ECDSA 公钥

使用 openssl (HEX) 生成 ECDSA 公钥

如何使用 openssl 生成十六进制 EC 密钥对?

示例输出:

ec private key: 1d6d6f979fe944658ef72336d0472d122d641c347d62af8b80cbd5a6d9595298
ec public key: 043ca2e15917499a0c7de20f03a17b82a0aab1450dcaa0d704c5d969090bc10a2b1e3e60ef1d17b5201b2c35b124058cb1e034305574dfccdffda9e895a813672b

答案1

openssl ecparam -name prime256v1 -genkey > /tmp/ecprivkey.pem
openssl ec -in /tmp/ecprivkey.pem -text -noout

将会打印出如下内容:

read EC key
Private-Key: (256 bit)
priv:
    78:5e:9a:be:d0:67:b8:93:65:00:bd:ec:95:43:36:
    d7:02:ba:ad:08:29:ae:51:1f:9e:cb:75:28:f7:0d:
    b0:fe
pub: 
    04:8c:18:af:2c:82:0a:04:c5:24:ca:50:14:05:3e:
    9c:1a:1b:d0:86:d4:95:3a:04:39:14:e2:f3:04:3c:
    5d:e3:28:98:bf:43:ec:a7:32:3f:e3:be:34:a8:b5:
    40:2a:5b:f6:7f:f0:8c:27:ae:d5:98:53:28:e8:37:
    97:15:ac:48:3d
ASN1 OID: prime256v1

其中包含您想要的内容;只需删除“ :”字符即可。

答案2

openssl genpkey -algorithm x25519 -text

相关内容