Documentation ¶
Index ¶
- Constants
- Variables
- func AddOidAsn1(name string, identifier asn1.ObjectIdentifier)
- func AddOidHash(name string, value func() hash.Hash)
- func AddRfc1423Algo(value rfc1423Algo)
- func DecryptPEMBlock(block *pem.Block, password []byte) ([]byte, error)
- func DecryptPKCS8PrivateKey(data, password []byte) ([]byte, error)
- func EncryptPKCS8PrivateKey(rand io.Reader, blockType string, data []byte, password []byte, ...) (*pem.Block, error)
- type Cryptobin
- func (this Cryptobin) AEADDecrypt() Cryptobin
- func (this Cryptobin) AEADEncrypt() Cryptobin
- func (this Cryptobin) Aes() Cryptobin
- func (this Cryptobin) AesCFBDecrypt() Cryptobin
- func (this Cryptobin) AesCFBEncrypt() Cryptobin
- func (this Cryptobin) AesECBDecrypt() Cryptobin
- func (this Cryptobin) AesECBEncrypt() Cryptobin
- func (this Cryptobin) AesECBGenerateKey(key []byte) (genKey []byte)
- func (this Cryptobin) Base64Decode(s string) ([]byte, error)
- func (this Cryptobin) Base64Encode(src []byte) string
- func (this Cryptobin) Blowfish(salt ...[]byte) Cryptobin
- func (this Cryptobin) CBC() Cryptobin
- func (this Cryptobin) CFB() Cryptobin
- func (this Cryptobin) CTR() Cryptobin
- func (this Cryptobin) Cast5() Cryptobin
- func (this Cryptobin) Chacha20(nonce []byte, counter ...uint32) Cryptobin
- func (this Cryptobin) Chacha20poly1305(nonce []byte, additional []byte) Cryptobin
- func (this Cryptobin) CipherBlock(key []byte) (cipher.Block, error)
- func (this Cryptobin) CipherDecrypt() Cryptobin
- func (this Cryptobin) CipherEncrypt() Cryptobin
- func (this Cryptobin) Decrypt() Cryptobin
- func (this Cryptobin) Des() Cryptobin
- func (this Cryptobin) ECB() Cryptobin
- func (this Cryptobin) Encrypt() Cryptobin
- func (this Cryptobin) FromBase64String(data string) Cryptobin
- func (this Cryptobin) FromBytes(data []byte) Cryptobin
- func (this Cryptobin) FromHexString(data string) Cryptobin
- func (this Cryptobin) FromString(data string) Cryptobin
- func (this Cryptobin) GCM(nonce []byte, additional []byte) Cryptobin
- func (this Cryptobin) GetConfig(key string) interface{}
- func (this Cryptobin) GetConfigs() map[string]interface{}
- func (this Cryptobin) GetData() []byte
- func (this Cryptobin) GetError() error
- func (this Cryptobin) GetIv() []byte
- func (this Cryptobin) GetKey() []byte
- func (this Cryptobin) GetMode() string
- func (this Cryptobin) GetPadding() string
- func (this Cryptobin) GetParsedData() []byte
- func (this Cryptobin) GetType() string
- func (this Cryptobin) HexDecode(s string) ([]byte, error)
- func (this Cryptobin) HexEncode(src []byte) string
- func (this Cryptobin) NoPadding() Cryptobin
- func (this Cryptobin) NoParsed() Cryptobin
- func (this Cryptobin) OFB() Cryptobin
- func (this Cryptobin) PKCS5Padding() Cryptobin
- func (this Cryptobin) PKCS7Padding() Cryptobin
- func (this Cryptobin) Padding(plainText []byte, blockSize int) []byte
- func (this Cryptobin) Pkcs5Padding(text []byte) []byte
- func (this Cryptobin) Pkcs5UnPadding(src []byte) []byte
- func (this Cryptobin) Pkcs7Padding(text []byte, blockSize int) []byte
- func (this Cryptobin) Pkcs7UnPadding(src []byte) []byte
- func (this Cryptobin) RC4() Cryptobin
- func (this Cryptobin) RsaDecrypt(password ...string) Cryptobin
- func (this Cryptobin) RsaEncrypt() Cryptobin
- func (this Cryptobin) RsaPrikeyEncrypt(password ...string) Cryptobin
- func (this Cryptobin) RsaPubkeyDecrypt() Cryptobin
- func (this Cryptobin) SetConfig(key string, value interface{}) Cryptobin
- func (this Cryptobin) SetIv(data string) Cryptobin
- func (this Cryptobin) SetKey(data string) Cryptobin
- func (this Cryptobin) String() string
- func (this Cryptobin) Tea(rounds ...int) Cryptobin
- func (this Cryptobin) ToBase64String() string
- func (this Cryptobin) ToBytes() []byte
- func (this Cryptobin) ToHexString() string
- func (this Cryptobin) ToString() string
- func (this Cryptobin) TriDes() Cryptobin
- func (this Cryptobin) Twofish() Cryptobin
- func (this Cryptobin) UnPadding(cipherText []byte) []byte
- func (this Cryptobin) WithConfig(config map[string]interface{}) Cryptobin
- func (this Cryptobin) WithData(data []byte) Cryptobin
- func (this Cryptobin) WithIv(data []byte) Cryptobin
- func (this Cryptobin) WithKey(data []byte) Cryptobin
- func (this Cryptobin) WithMode(data string) Cryptobin
- func (this Cryptobin) WithPadding(data string) Cryptobin
- func (this Cryptobin) WithType(data string) Cryptobin
- func (this Cryptobin) Xtea() Cryptobin
- func (this Cryptobin) ZeroPadding() Cryptobin
- func (this Cryptobin) ZerosPadding(text []byte, blockSize int) []byte
- func (this Cryptobin) ZerosUnPadding(src []byte) []byte
- type Ecdsa
- func EcdsaFromBase64String(data string) Ecdsa
- func EcdsaFromBytes(data []byte) Ecdsa
- func EcdsaFromHexString(data string) Ecdsa
- func EcdsaFromPrivateKey(key []byte) Ecdsa
- func EcdsaFromPublicKey(key []byte) Ecdsa
- func EcdsaFromString(data string) Ecdsa
- func EcdsaGenerateKey(hash string) Ecdsa
- func NewEcdsa() Ecdsa
- func (this Ecdsa) Base64Decode(s string) ([]byte, error)
- func (this Ecdsa) Base64Encode(src []byte) string
- func (this Ecdsa) CreatePrivateKey() Ecdsa
- func (this Ecdsa) CreatePublicKey() Ecdsa
- func (this Ecdsa) DataHash(signHash string, data []byte) []byte
- func (this Ecdsa) FromBase64String(data string) Ecdsa
- func (this Ecdsa) FromBytes(data []byte) Ecdsa
- func (this Ecdsa) FromHexString(data string) Ecdsa
- func (this Ecdsa) FromPrivateKey(key []byte) Ecdsa
- func (this Ecdsa) FromPublicKey(key []byte) Ecdsa
- func (this Ecdsa) FromString(data string) Ecdsa
- func (this Ecdsa) GenerateKey() Ecdsa
- func (this Ecdsa) GetData() []byte
- func (this Ecdsa) GetError() error
- func (this Ecdsa) GetKeyData() []byte
- func (this Ecdsa) GetParedData() []byte
- func (this Ecdsa) GetPrivateKey() *ecdsa.PrivateKey
- func (this Ecdsa) GetPublicKey() *ecdsa.PublicKey
- func (this Ecdsa) GetSignHash() string
- func (this Ecdsa) GetVeryed() bool
- func (this Ecdsa) HexDecode(s string) ([]byte, error)
- func (this Ecdsa) HexEncode(src []byte) string
- func (this Ecdsa) ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error)
- func (this Ecdsa) ParseECPublicKeyFromPEM(key []byte) (*ecdsa.PublicKey, error)
- func (this Ecdsa) Sign(separator ...string) Ecdsa
- func (this Ecdsa) ToBase64String() string
- func (this Ecdsa) ToBytes() []byte
- func (this Ecdsa) ToHexString() string
- func (this Ecdsa) ToKeyBytes() []byte
- func (this Ecdsa) ToKeyString() string
- func (this Ecdsa) ToString() string
- func (this Ecdsa) ToVeryed() bool
- func (this Ecdsa) Very(data []byte, separator ...string) Ecdsa
- func (this Ecdsa) WithCurve(hash string) Ecdsa
- func (this Ecdsa) WithData(data []byte) Ecdsa
- func (this Ecdsa) WithError(err error) Ecdsa
- func (this Ecdsa) WithParedData(data []byte) Ecdsa
- func (this Ecdsa) WithPrivateKey(data *ecdsa.PrivateKey) Ecdsa
- func (this Ecdsa) WithPublicKey(data *ecdsa.PublicKey) Ecdsa
- func (this Ecdsa) WithSignHash(data string) Ecdsa
- type EdDSA
- func EdDSAFromBase64String(data string) EdDSA
- func EdDSAFromBytes(data []byte) EdDSA
- func EdDSAFromHexString(data string) EdDSA
- func EdDSAFromPrivateKey(key []byte) EdDSA
- func EdDSAFromPublicKey(key []byte) EdDSA
- func EdDSAFromString(data string) EdDSA
- func EdDSAGenerateKey() EdDSA
- func NewEdDSA() EdDSA
- func (this EdDSA) Base64Decode(s string) ([]byte, error)
- func (this EdDSA) Base64Encode(src []byte) string
- func (this EdDSA) CreatePrivateKey() EdDSA
- func (this EdDSA) CreatePublicKey() EdDSA
- func (this EdDSA) FromBase64String(data string) EdDSA
- func (this EdDSA) FromBytes(data []byte) EdDSA
- func (this EdDSA) FromHexString(data string) EdDSA
- func (this EdDSA) FromPrivateKey(key []byte) EdDSA
- func (this EdDSA) FromPublicKey(key []byte) EdDSA
- func (this EdDSA) FromString(data string) EdDSA
- func (this EdDSA) GenerateKey() EdDSA
- func (this EdDSA) GetData() []byte
- func (this EdDSA) GetError() error
- func (this EdDSA) GetKeyData() []byte
- func (this EdDSA) GetParedData() []byte
- func (this EdDSA) GetPrivateKey() ed25519.PrivateKey
- func (this EdDSA) GetPublicKey() ed25519.PublicKey
- func (this EdDSA) GetVeryed() bool
- func (this EdDSA) HexDecode(s string) ([]byte, error)
- func (this EdDSA) HexEncode(src []byte) string
- func (this EdDSA) ParseEdPrivateKeyFromPEM(key []byte) (crypto.PrivateKey, error)
- func (this EdDSA) ParseEdPublicKeyFromPEM(key []byte) (crypto.PublicKey, error)
- func (this EdDSA) Sign() EdDSA
- func (this EdDSA) ToBase64String() string
- func (this EdDSA) ToBytes() []byte
- func (this EdDSA) ToHexString() string
- func (this EdDSA) ToKeyBytes() []byte
- func (this EdDSA) ToKeyString() string
- func (this EdDSA) ToString() string
- func (this EdDSA) ToVeryed() bool
- func (this EdDSA) Very(data []byte) EdDSA
- func (this EdDSA) WithData(data []byte) EdDSA
- func (this EdDSA) WithError(err error) EdDSA
- func (this EdDSA) WithParedData(data []byte) EdDSA
- func (this EdDSA) WithPrivateKey(data ed25519.PrivateKey) EdDSA
- func (this EdDSA) WithPublicKey(data ed25519.PublicKey) EdDSA
- type Opts
- type Rsa
- func NewRsa() Rsa
- func RsaFromBase64String(data string) Rsa
- func RsaFromBytes(data []byte) Rsa
- func RsaFromHexString(data string) Rsa
- func RsaFromPKCS1(key []byte) Rsa
- func RsaFromPKCS1WithPassword(key []byte, password string) Rsa
- func RsaFromPKCS8(key []byte) Rsa
- func RsaFromPKCS8WithPassword(key []byte, password string) Rsa
- func RsaFromPrivateKey(key []byte) Rsa
- func RsaFromPrivateKeyWithPassword(key []byte, password string) Rsa
- func RsaFromPublicKey(key []byte) Rsa
- func RsaFromString(data string) Rsa
- func RsaFromYoumarkPKCS8WithPassword(key []byte, password string) Rsa
- func RsaGenerateKey(bits int) Rsa
- func (this Rsa) Base64Decode(s string) ([]byte, error)
- func (this Rsa) Base64Encode(src []byte) string
- func (this Rsa) CreatePKCS1() Rsa
- func (this Rsa) CreatePKCS1WithPassword(password string, opts ...string) Rsa
- func (this Rsa) CreatePKCS8() Rsa
- func (this Rsa) CreatePKCS8WithPassword(password string, opts ...string) Rsa
- func (this Rsa) CreatePublicKey() Rsa
- func (this Rsa) CreateYoumarkPKCS8WithPassword(password string, opt ...youmarkPkcs8.Opts) Rsa
- func (this Rsa) DataHash(signHash string, data []byte) []byte
- func (this Rsa) Decrypt() Rsa
- func (this Rsa) Encrypt() Rsa
- func (this Rsa) FromBase64String(data string) Rsa
- func (this Rsa) FromBytes(data []byte) Rsa
- func (this Rsa) FromHexString(data string) Rsa
- func (this Rsa) FromPKCS1(key []byte) Rsa
- func (this Rsa) FromPKCS1WithPassword(key []byte, password string) Rsa
- func (this Rsa) FromPKCS8(key []byte) Rsa
- func (this Rsa) FromPKCS8WithPassword(key []byte, password string) Rsa
- func (this Rsa) FromPrivateKey(key []byte) Rsa
- func (this Rsa) FromPrivateKeyWithPassword(key []byte, password string) Rsa
- func (this Rsa) FromPublicKey(key []byte) Rsa
- func (this Rsa) FromString(data string) Rsa
- func (this Rsa) FromYoumarkPKCS8WithPassword(key []byte, password string) Rsa
- func (this Rsa) GenerateKey(bits int) Rsa
- func (this Rsa) GetData() []byte
- func (this Rsa) GetError() error
- func (this Rsa) GetKeyData() []byte
- func (this Rsa) GetParedData() []byte
- func (this Rsa) GetPrivateKey() *rsa.PrivateKey
- func (this Rsa) GetPublicKey() *rsa.PublicKey
- func (this Rsa) GetSignHash() string
- func (this Rsa) GetVeryed() bool
- func (this Rsa) HashType(signHash string) crypto.Hash
- func (this Rsa) HexDecode(s string) ([]byte, error)
- func (this Rsa) HexEncode(src []byte) string
- func (this Rsa) PSSSign(opts ...rsa.PSSOptions) Rsa
- func (this Rsa) PSSVery(data []byte, opts ...rsa.PSSOptions) Rsa
- func (this Rsa) ParseRSAPKCS8PrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
- func (this Rsa) ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
- func (this Rsa) ParseRSAPrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
- func (this Rsa) ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error)
- func (this Rsa) PriKeyEncrypt() Rsa
- func (this Rsa) PubKeyDecrypt() Rsa
- func (this Rsa) Sign() Rsa
- func (this Rsa) ToBase64String() string
- func (this Rsa) ToBytes() []byte
- func (this Rsa) ToHexString() string
- func (this Rsa) ToKeyBytes() []byte
- func (this Rsa) ToKeyString() string
- func (this Rsa) ToString() string
- func (this Rsa) ToVeryed() bool
- func (this Rsa) Very(data []byte) Rsa
- func (this Rsa) WithData(data []byte) Rsa
- func (this Rsa) WithError(err error) Rsa
- func (this Rsa) WithParedData(data []byte) Rsa
- func (this Rsa) WithPrivateKey(data *rsa.PrivateKey) Rsa
- func (this Rsa) WithPublicKey(data *rsa.PublicKey) Rsa
- func (this Rsa) WithSignHash(data string) Rsa
Constants ¶
const PBKDF2Iterations = 10000
PBKDF2Iterations is the default number of iterations for PBKDF2, 100k iterations. Nist recommends at least 10k, 1Passsword uses 100k.
const PBKDF2SaltSize = 16
PBKDF2SaltSize is the default size of the salt for PBKDF2, 128-bit salt.
Variables ¶
var ( ErrNotECPublicKey = errors.New("key is not a valid ECDSA public key") ErrNotECPrivateKey = errors.New("key is not a valid ECDSA private key") )
var ( ErrNotEdPrivateKey = errors.New("key is not a valid Ed25519 private key") ErrNotEdPublicKey = errors.New("key is not a valid Ed25519 public key") )
var ( ErrDataToLarge = errors.New("message too long for RSA public key size") ErrDataLen = errors.New("data length error") ErrDataBroken = errors.New("data broken, first byte is not zero") ErrKeyPairDismatch = errors.New("data is not encrypted by the private key") ErrDecryption = errors.New("decryption error") )
var ( ErrKeyMustBePEMEncoded = errors.New("invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key") ErrNotRSAPrivateKey = errors.New("key is not a valid RSA private key") ErrNotRSAPublicKey = errors.New("key is not a valid RSA public key") )
var ( // 创建私钥默认可用选项 // HMACHash 目前支持 SHA256 和 SHA1 Youmark_AES128CBC_SHA256 = youmarkPkcs8.Opts{ Cipher: youmarkPkcs8.AES128CBC, KDFOpts: youmarkPkcs8.PBKDF2Opts{ SaltSize: 8, IterationCount: 2048, HMACHash: crypto.SHA256, }, } Youmark_AES192CBC_SHA256 = youmarkPkcs8.Opts{ Cipher: youmarkPkcs8.AES192CBC, KDFOpts: youmarkPkcs8.PBKDF2Opts{ SaltSize: 8, IterationCount: 1000, HMACHash: crypto.SHA256, }, } Youmark_AES256CBC_SHA256 = youmarkPkcs8.Opts{ Cipher: youmarkPkcs8.AES256CBC, KDFOpts: youmarkPkcs8.PBKDF2Opts{ SaltSize: 16, IterationCount: 2000, HMACHash: crypto.SHA256, }, } Youmark_AES128GCM_SHA256 = youmarkPkcs8.Opts{ Cipher: youmarkPkcs8.AES128GCM, KDFOpts: youmarkPkcs8.PBKDF2Opts{ SaltSize: 8, IterationCount: 2048, HMACHash: crypto.SHA256, }, } Youmark_AES192GCM_SHA256 = youmarkPkcs8.Opts{ Cipher: youmarkPkcs8.AES192GCM, KDFOpts: youmarkPkcs8.PBKDF2Opts{ SaltSize: 8, IterationCount: 10000, HMACHash: crypto.SHA256, }, } Youmark_AES256GCM_SHA256 = youmarkPkcs8.Opts{ Cipher: youmarkPkcs8.AES256GCM, KDFOpts: youmarkPkcs8.PBKDF2Opts{ SaltSize: 16, IterationCount: 16, HMACHash: crypto.SHA256, }, } Youmark_TripleDESCBC_SHA1 = youmarkPkcs8.Opts{ Cipher: youmarkPkcs8.TripleDESCBC, KDFOpts: youmarkPkcs8.PBKDF2Opts{ SaltSize: 16, IterationCount: 16, HMACHash: crypto.SHA1, }, } Youmark_AES256CBC_Scrypt = youmarkPkcs8.Opts{ Cipher: youmarkPkcs8.AES256CBC, KDFOpts: youmarkPkcs8.ScryptOpts{ CostParameter: 1 << 2, BlockSize: 8, ParallelizationParameter: 1, SaltSize: 16, }, } )
var DefaultOpts = &Opts{ SaltSize: PBKDF2SaltSize, IterationCount: PBKDF2Iterations, HMACHash: "SHA256", }
默认配置
var PEMCiphers = map[string]x509.PEMCipher{ "DESCBC": x509.PEMCipherDES, "DESEDE3CBC": x509.PEMCipher3DES, "AES128CBC": x509.PEMCipherAES128, "AES192CBC": x509.PEMCipherAES192, "AES256CBC": x509.PEMCipherAES256, }
pem 加密方式
Functions ¶
func DecryptPEMBlock ¶
解出 PEM 块
func DecryptPKCS8PrivateKey ¶
解出 PKCS8 密钥 加密方式: AES-128-CBC | AES-192-CBC | AES-256-CBC | DES | 3DES
Types ¶
type Cryptobin ¶
type Cryptobin struct { // 错误 Error error // contains filtered or unexported fields }
*
- 对称加密 *
- @create 2022-3-19
- @author deatil
func (Cryptobin) AesECBDecrypt ¶
func (Cryptobin) AesECBEncrypt ¶
func (Cryptobin) AesECBGenerateKey ¶
func (Cryptobin) Base64Decode ¶
Base64 解码
func (Cryptobin) Chacha20poly1305 ¶ added in v1.0.2
Chacha20poly1305 nonce is 12 bytes
func (Cryptobin) CipherBlock ¶
Cipher
func (Cryptobin) FromBase64String ¶
Base64
func (Cryptobin) Pkcs5Padding ¶
PKCS7Padding的子集,块大小固定为8字节
func (Cryptobin) Pkcs5UnPadding ¶
func (Cryptobin) Pkcs7Padding ¶
明文补码算法
func (Cryptobin) RsaDecrypt ¶
RSA 私钥解密 pkcs8 带密码不支持其他工具生成的密钥
func (Cryptobin) RsaPrikeyEncrypt ¶
RSA 私钥加密 pkcs8 带密码不支持其他工具生成的密钥
func (Cryptobin) WithConfig ¶
配置
func (Cryptobin) ZerosPadding ¶
数据长度不对齐时使用0填充,否则不填充
func (Cryptobin) ZerosUnPadding ¶
type Ecdsa ¶
type Ecdsa struct { // 错误 Error error // contains filtered or unexported fields }
*
- Ecdsa *
- @create 2022-4-3
- @author deatil
func EcdsaGenerateKey ¶
生成密钥 可选 [P521 | P384 | P256 | P224]
func (Ecdsa) ParseECPrivateKeyFromPEM ¶
func (this Ecdsa) ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error)
解析私钥
func (Ecdsa) ParseECPublicKeyFromPEM ¶
解析公钥
func (Ecdsa) WithPrivateKey ¶
func (this Ecdsa) WithPrivateKey(data *ecdsa.PrivateKey) Ecdsa
设置 PrivateKey
func (Ecdsa) WithPublicKey ¶
设置 PublicKey
type EdDSA ¶ added in v1.0.2
type EdDSA struct { // 错误 Error error // contains filtered or unexported fields }
*
- EdDSA *
- @create 2022-4-3
- @author deatil
func (EdDSA) Base64Decode ¶ added in v1.0.2
Base64 解码
func (EdDSA) Base64Encode ¶ added in v1.0.2
Base64 编码
func (EdDSA) FromBase64String ¶ added in v1.0.2
Base64
func (EdDSA) GetPrivateKey ¶ added in v1.0.2
func (this EdDSA) GetPrivateKey() ed25519.PrivateKey
获取 PrivateKey
func (EdDSA) GetPublicKey ¶ added in v1.0.2
获取 PublicKey
func (EdDSA) ParseEdPrivateKeyFromPEM ¶ added in v1.0.2
func (this EdDSA) ParseEdPrivateKeyFromPEM(key []byte) (crypto.PrivateKey, error)
解析私钥
func (EdDSA) ParseEdPublicKeyFromPEM ¶ added in v1.0.2
解析公钥
func (EdDSA) WithParedData ¶ added in v1.0.2
设置 paredData
func (EdDSA) WithPrivateKey ¶ added in v1.0.2
func (this EdDSA) WithPrivateKey(data ed25519.PrivateKey) EdDSA
设置 PrivateKey
type Rsa ¶
type Rsa struct { // 错误 Error error // contains filtered or unexported fields }
*
- Rsa 加密 *
- @create 2021-8-28
- @author deatil
func RsaFromPKCS1WithPassword ¶
Pkcs1WithPassword
func RsaFromPKCS8WithPassword ¶
Pkcs8WithPassword
func RsaFromPrivateKeyWithPassword ¶
私钥带密码
func RsaFromYoumarkPKCS8WithPassword ¶
设置私钥带密码
func (Rsa) CreatePKCS1WithPassword ¶
PKCS1 私钥带密码 CreatePKCS1WithPassword("123", "AES256CBC")
func (Rsa) CreatePKCS8WithPassword ¶
PKCS8 私钥带密码 CreatePKCS8WithPassword("123", "AES256CBC", "SHA256")
func (Rsa) CreateYoumarkPKCS8WithPassword ¶
func (this Rsa) CreateYoumarkPKCS8WithPassword(password string, opt ...youmarkPkcs8.Opts) Rsa
创建私钥带密码
func (Rsa) FromPKCS1WithPassword ¶
Pkcs1WithPassword
func (Rsa) FromPKCS8WithPassword ¶
Pkcs8WithPassword
func (Rsa) FromPrivateKeyWithPassword ¶
私钥带密码
func (Rsa) FromYoumarkPKCS8WithPassword ¶
设置私钥带密码
func (Rsa) GenerateKey ¶
生成密钥 bits = 512 | 1024 | 2048 | 4096
func (Rsa) PSSSign ¶ added in v1.0.2
func (this Rsa) PSSSign(opts ...rsa.PSSOptions) Rsa
私钥签名 常用为: PS256[SHA256] | PS384[SHA384] | PS512[SHA512]
func (Rsa) PSSVery ¶ added in v1.0.2
func (this Rsa) PSSVery(data []byte, opts ...rsa.PSSOptions) Rsa
公钥验证 使用原始数据[data]对比签名后数据
func (Rsa) ParseRSAPKCS8PrivateKeyFromPEMWithPassword ¶
func (this Rsa) ParseRSAPKCS8PrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
解析 PKCS8 带密码的私钥
func (Rsa) ParseRSAPrivateKeyFromPEM ¶
func (this Rsa) ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
解析 PKCS1 / PKCS8 私钥
func (Rsa) ParseRSAPrivateKeyFromPEMWithPassword ¶
func (this Rsa) ParseRSAPrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
解析 PKCS1 带密码的私钥
func (Rsa) ParseRSAPublicKeyFromPEM ¶
解析 PKCS1 / PKCS8 公钥
Source Files ¶
- cryptobin.go
- ecdsa.go
- ecdsa_create.go
- ecdsa_encoding.go
- ecdsa_from.go
- ecdsa_get.go
- ecdsa_helper.go
- ecdsa_parse.go
- ecdsa_sign.go
- ecdsa_to.go
- ecdsa_with.go
- eddsa.go
- eddsa_create.go
- eddsa_encoding.go
- eddsa_from.go
- eddsa_get.go
- eddsa_helper.go
- eddsa_parse.go
- eddsa_sign.go
- eddsa_to.go
- eddsa_with.go
- encoding.go
- encryption.go
- encryption_aead.go
- encryption_cipher.go
- encryption_rsa.go
- from.go
- get.go
- helper.go
- padding.go
- rsa.go
- rsa_create.go
- rsa_encoding.go
- rsa_encodingkey.go
- rsa_encryption.go
- rsa_from.go
- rsa_get.go
- rsa_helper.go
- rsa_parse.go
- rsa_pkcs8.go
- rsa_pss_sign.go
- rsa_sign.go
- rsa_to.go
- rsa_with.go
- rsa_youmark.go
- special.go
- to.go
- use.go
- with.go