Class Asymmetric<T extends Asymmetric<T>>
java.lang.Object
org.miaixz.bus.crypto.builtin.asymmetric.Asymmetric<T>
- Type Parameters:
T- this类型
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AbstractCrypto,Sign
非对称基础,提供锁、私钥和公钥的持有
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String算法protected Lock锁protected PrivateKey私钥protected PublicKey公钥 -
Constructor Summary
ConstructorsConstructorDescriptionAsymmetric(String algorithm, KeyPair keyPair) 构造 私钥和公钥同时为空时生成一对新的私钥和公钥 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密 -
Method Summary
Modifier and TypeMethodDescriptionprotected KeygetKeyByType(KeyType type) 根据密钥类型获得相应密钥获得私钥获得私钥获得公钥获得公钥protected T初始化 私钥和公钥同时为空时生成一对新的私钥和公钥 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密(签名)或者解密(校验)initKeys()生成随机公钥和私钥设置密钥,可以是公钥PublicKey或者私钥PrivateKey自定义锁,无需锁使用NoLocksetPrivateKey(PrivateKey privateKey) 设置私钥setPublicKey(PublicKey publicKey) 设置公钥
-
Field Details
-
algorithm
算法 -
publicKey
公钥 -
privateKey
私钥 -
lock
锁
-
-
Constructor Details
-
Asymmetric
-
-
Method Details
-
init
-
initKeys
-
setLock
-
getPublicKey
-
setPublicKey
-
getPublicKeyBase64
-
getPrivateKey
-
setPrivateKey
-
getPrivateKeyBase64
-
setKey
设置密钥,可以是公钥PublicKey或者私钥PrivateKey- Parameters:
key- 密钥,可以是公钥PublicKey或者私钥PrivateKey- Returns:
- this
-
getKeyByType
-