Documentation
¶
Index ¶
- Variables
- func GetCurveFromName(name string) ecdh.Curve
- type Ecdh
- func (this Ecdh) CreateKdfPrivateKeyWithPassword(password string, opts ...any) Ecdh
- func (this Ecdh) CreatePbePrivateKeyWithPassword(password string, alg string) Ecdh
- func (this Ecdh) CreatePrivateKey() Ecdh
- func (this Ecdh) CreatePrivateKeyWithPassword(password string, opts ...any) Ecdh
- func (this Ecdh) CreatePublicKey() Ecdh
- func (this Ecdh) CreateSecret() Ecdh
- func (this Ecdh) FromKeyXYHexString(curve string, xString string, yString string) Ecdh
- func (this Ecdh) FromPrivateKey(key []byte) Ecdh
- func (this Ecdh) FromPrivateKeyWithPassword(key []byte, password string) Ecdh
- func (this Ecdh) FromPrivateKeyXHexString(curve string, xString string) Ecdh
- func (this Ecdh) FromPublicKey(key []byte) Ecdh
- func (this Ecdh) FromPublicKeyYHexString(curve string, yString string) Ecdh
- func (this Ecdh) GenerateKey(curve string) Ecdh
- func (this Ecdh) GetError() error
- func (this Ecdh) GetKeyData() []byte
- func (this Ecdh) GetPrivateKey() *ecdh.PrivateKey
- func (this Ecdh) GetPrivateKeyXHexString() string
- func (this Ecdh) GetPublicKey() *ecdh.PublicKey
- func (this Ecdh) GetPublicKeyYHexString() string
- func (this Ecdh) MakePublicKey() Ecdh
- func (this Ecdh) OnError(fn ErrorFunc) Ecdh
- func (this Ecdh) ParsePrivateKeyFromPEM(key []byte) (crypto.PrivateKey, error)
- func (this Ecdh) ParsePrivateKeyFromPEMWithPassword(key []byte, password string) (crypto.PrivateKey, error)
- func (this Ecdh) ParsePublicKeyFromPEM(key []byte) (crypto.PublicKey, error)
- func (this Ecdh) ToBase64String() string
- func (this Ecdh) ToBytes() []byte
- func (this Ecdh) ToHexString() string
- func (this Ecdh) ToKeyBytes() []byte
- func (this Ecdh) ToKeyString() string
- func (this Ecdh) ToString() string
- func (this Ecdh) WithError(err error) Ecdh
- func (this Ecdh) WithKeyData(data []byte) Ecdh
- func (this Ecdh) WithPrivateKey(data *ecdh.PrivateKey) Ecdh
- func (this Ecdh) WithPublicKey(data *ecdh.PublicKey) Ecdh
- type ErrorFunc
- type Opts
- type PBKDF2Opts
- type ScryptOpts
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // 获取 Cipher 类型 GetCipherFromName = cryptobin_pkcs8.GetCipherFromName // 获取 hash 类型 GetHashFromName = cryptobin_pkcs8.GetHashFromName )
View Source
var ( ErrKeyMustBePEMEncoded = errors.New("invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key") ErrNotPrivateKey = errors.New("key is not a valid ecdh private key") ErrNotPublicKey = errors.New("key is not a valid ecdh public key") )
View Source
var PEMCiphers = map[string]x509.PEMCipher{ "DESCBC": x509.PEMCipherDES, "DESEDE3CBC": x509.PEMCipher3DES, "AES128CBC": x509.PEMCipherAES128, "AES192CBC": x509.PEMCipherAES192, "AES256CBC": x509.PEMCipherAES256, }
pem 加密方式
Functions ¶
Types ¶
type Ecdh ¶
type Ecdh struct { // 错误 Error error // contains filtered or unexported fields }
*
- ecdh *
- @create 2022-8-7
- @author deatil
func (Ecdh) CreateKdfPrivateKeyWithPassword ¶
生成私钥带密码 pem 数据 CreateKdfPrivateKeyWithPassword("123", "AES256CBC", "SHA256")
func (Ecdh) CreatePbePrivateKeyWithPassword ¶
生成 PKCS8 私钥带密码 pem 数据
func (Ecdh) CreatePrivateKey ¶
生成私钥 pem 数据 使用: obj := New().GenerateKey("P2048") priKey := obj.CreatePrivateKey().ToKeyString()
func (Ecdh) CreatePrivateKeyWithPassword ¶
生成 PKCS8 私钥带密码 pem 数据 CreatePrivateKeyWithPassword("123", "AES256CBC", "SHA256")
func (Ecdh) FromKeyXYHexString ¶ added in v1.0.1025
根据私钥 x, y 生成
func (Ecdh) FromPrivateKeyWithPassword ¶
私钥带密码
func (Ecdh) FromPrivateKeyXHexString ¶ added in v1.0.1025
根据私钥 x 生成
func (Ecdh) FromPublicKeyYHexString ¶ added in v1.0.1025
根据公钥 y 生成
func (Ecdh) GenerateKey ¶
生成密钥 可用参数 [P521 | P384 | P256 | P224]
func (Ecdh) GetPrivateKeyXHexString ¶ added in v1.0.1025
获取 X 16进制字符
func (Ecdh) GetPublicKeyYHexString ¶ added in v1.0.1025
获取 Y 16进制字符
func (Ecdh) ParsePrivateKeyFromPEM ¶
func (this Ecdh) ParsePrivateKeyFromPEM(key []byte) (crypto.PrivateKey, error)
解析私钥
func (Ecdh) ParsePrivateKeyFromPEMWithPassword ¶
func (this Ecdh) ParsePrivateKeyFromPEMWithPassword(key []byte, password string) (crypto.PrivateKey, error)
解析私钥带密码
func (Ecdh) ParsePublicKeyFromPEM ¶
解析公钥
func (Ecdh) WithPrivateKey ¶
func (this Ecdh) WithPrivateKey(data *ecdh.PrivateKey) Ecdh
设置 PrivateKey
Click to show internal directories.
Click to hide internal directories.