Documentation ¶
Index ¶
- func BuildSecretKey(keyValue string) string
- func BytePrivateKey(privateKey interface{}, password []byte, byteType string) []byte
- func BytePublicKey(pubkey interface{}) []byte
- func DecodeBase64(cipherText string) []byte
- func DecodeHexUpper(str string) []byte
- func Decrypt(privateKey interface{}, ciphertext []byte) []byte
- func DecryptKey(keyValue []byte, privateKey interface{}) []byte
- func DecryptSymmetrical(key []byte, ciphertext []byte, mode string) []byte
- func EncodeBase64(raw []byte) string
- func EncodeHex(data []byte) string
- func EncodeHmac(data, key []byte, mode string) []byte
- func Encrypt(publicKey interface{}, plaintext []byte) []byte
- func EncryptKey(key []byte, publicKey interface{}) []byte
- func EncryptSymmetrical(key []byte, plaintext []byte, mode string) []byte
- func GenerateCert(parent *x509.Certificate, notBefore time.Time, notAfter time.Time, ...) *pem.Block
- func GenerateKeyPair(keyType string) interface{}
- func GenerateSecretKey(length int) string
- func GetPrivateKey(keyPair interface{}, password string, pos int) interface{}
- func GetPublicKey(keyPair interface{}) crypto.PublicKey
- func Hash(plaintext string, mode string) []byte
- func LoadCert(buf []byte, password string) *x509.Certificate
- func LoadPrivateKey(keyValue []byte, password string, byteType string) interface{}
- func LoadPublicKey(keyValue []byte, byteType string) interface{}
- func ReadPEMFile(fileName string) *pem.Block
- func ReadSecretKey(keyValue []byte, privateKey interface{}) []byte
- func Sign(privateKey *ecdsa.PrivateKey, plaintext string) ([]byte, []byte)
- func ValidateKey(keypair *ecdsa.PrivateKey) bool
- func Verify(publicKey *ecdsa.PublicKey, plaintext string, rtext, stext []byte) bool
- func WritePEMFile(fileName string, block *pem.Block)
- func WritePrivateKey(privateKey interface{}, password []byte, byteType string) string
- func WritePublicKey(publicKey interface{}) string
- func WriteSecretKey(key []byte, publicKey *ecdsa.PublicKey) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytePrivateKey ¶
func BytePublicKey ¶
func BytePublicKey(pubkey interface{}) []byte
func DecodeBase64 ¶
func Decrypt ¶
*
- 非对称解密 *
- @param privkey 解密的密钥
- @param ciphertext 已经加密的数据
- @return 解密后的明文
- @throws EncryptException
func DecryptKey ¶
func DecryptSymmetrical ¶
*
- 对称解密 *
- @param key 解密的密钥
- @param raw 已经加密的数据
- @return 解密后的明文
- @throws EncryptException
func EncodeBase64 ¶
func Encrypt ¶
*
- 非对称加密 *
- @param key 加密的密钥
- @param data 待加密的明文数据
- @return 加密后的数据
- @throws EncryptException
func EncryptSymmetrical ¶
*
- 对称加密 *
- @param key 加密的密钥 The key argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256
- @param data 待加密的明文数据
- @return 加密后的数据
- @throws EncryptException
func GenerateCert ¶
func GenerateCert(parent *x509.Certificate, notBefore time.Time, notAfter time.Time, subject *pkix.Name, password string, keyPair *ecdsa.PrivateKey) *pem.Block
*
- 根据用户名和密钥对生成 X509 证书 * *
- @param user
- @param keyPair
- @return
func GetPrivateKey ¶
func GetPublicKey ¶
func LoadPublicKey ¶
*
- 从公钥字符串表示中还原公钥 * *
- @param keyValue
- @return
- @throws NoSuchAlgorithmException
- @throws InvalidKeySpecException
func ReadPEMFile ¶
func ReadSecretKey ¶
func ValidateKey ¶
func ValidateKey(keypair *ecdsa.PrivateKey) bool
func WritePEMFile ¶
func WritePrivateKey ¶
func WritePublicKey ¶
func WritePublicKey(publicKey interface{}) string
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.