Documentation ¶
Index ¶
- Variables
- func Base64Decode(data string) ([]byte, error)
- func Base64DecodeURL(data string) ([]byte, error)
- func Base64Encode(data []byte) string
- func Base64EncodeURL(data []byte) string
- func CRC32Cp(data []byte) uint32
- func CRC32IEEE(data []byte) uint32
- func CRC32Kp(data []byte) uint32
- func CRC64ECMA(data []byte) uint64
- func CRC64ISO(data []byte) uint64
- func EncodePrivateKeyBufferRSA(priKey *rsa.PrivateKey) []byte
- func EncodePrivateKeyFileRSA(priKey *rsa.PrivateKey, fileName string) error
- func EncodePublicKeyBufferRSA(pubKey *rsa.PublicKey) ([]byte, error)
- func EncodePublicKeyFileRSA(pubKey *rsa.PublicKey, fileName string) error
- func GenerateKeyRSA(bits int) (*rsa.PrivateKey, *rsa.PublicKey, error)
- func GetCertBytes(cert *pem.Block, key *pem.Block) ([]byte, []byte)
- func GetHmacSha256Hex(key string, data []byte) string
- func IsAccountEn(str string) (bool, error)
- func IsAccountZh(str string) (bool, error)
- func IsEmail(str string) (bool, error)
- func IsIPPort(str string) (bool, error)
- func IsIPv4(str string) (bool, error)
- func IsPhone(str string) (bool, error)
- func IssueCertImpl(rootCa *x509.Certificate, rootKey *rsa.PrivateKey) (*pem.Block, *pem.Block, error)
- func LoadPublicKeyRSA(pubKey []byte) (*rsa.PublicKey, error)
- func LoadRSAPrivateKeyPKCS1(priKey []byte) (*rsa.PrivateKey, error)
- func LoadRSAPrivateKeyPKCS8(priKey []byte) (*rsa.PrivateKey, error)
- func LoadRootCa(caFile string, keyFile string) (*x509.Certificate, *rsa.PrivateKey, error)
- func MD5(data []byte) ([]byte, error)
- func Number(maxNum uint64) (uint64, error)
- func Password(length uint64) (string, error)
- func RsaDecryptRSA(cipherText []byte, myPriKey *rsa.PrivateKey) ([]byte, error)
- func RsaEncryptRSA(plainText []byte, peerPubKey *rsa.PublicKey) ([]byte, error)
- func SaveCert2File(cert *pem.Block, key *pem.Block, certFile string, keyFile string) error
- func Sha1(data []byte) ([]byte, error)
- func Sha256(data []byte) ([]byte, error)
- func Sha512(data []byte) ([]byte, error)
- func SignWithSha256RSA(data []byte, myPriKey []byte) ([]byte, error)
- func String(length int) (string, error)
- func VerySignWithSha256RSA(originalDataHash []byte, signedDataHash []byte, peerPubKey []byte) error
- type Curve22519Ecdh
Constants ¶
This section is empty.
Variables ¶
var ( VisualCharAll = 0 VisualCharNumber = 1 VisualCharCapital = 2 VisualCharLowercase = 3 VisualCharSpecial = 4 )
var CapitalCharList = make([]uint64, 26)
var CapitalCharMap = make(map[byte]uint64)
var LowercaseCharList = make([]uint64, 26)
var LowercaseCharMap = make(map[byte]uint64)
var NumberCharList = make([]uint64, 10)
var NumberCharMap = make(map[byte]uint64)
var SpecialCharList = make([]uint64, 128)
var SpecialCharMap = make(map[byte]uint64)
var VisualCharList = make([]uint64, 256)
Functions ¶
func Base64DecodeURL ¶
Base64DecodeURL base64 url decode.
func EncodePrivateKeyBufferRSA ¶
func EncodePrivateKeyBufferRSA(priKey *rsa.PrivateKey) []byte
EncodePrivateKeyBufferRSA format RSA private key as bytes.
func EncodePrivateKeyFileRSA ¶
func EncodePrivateKeyFileRSA(priKey *rsa.PrivateKey, fileName string) error
EncodePrivateKeyFileRSA format RSA private key as file.
func EncodePublicKeyBufferRSA ¶
EncodePublicKeyBufferRSA format RSA public key as bytes.
func EncodePublicKeyFileRSA ¶
EncodePublicKeyFileRSA format RSA public key as file.
func GenerateKeyRSA ¶
GenerateKeyRSA generate RSA public and private key pair.
func GetCertBytes ¶
GetCertBytes Save the certificate as bytes.
func GetHmacSha256Hex ¶
func IsAccountEn ¶
IsAccountEn is english account, windows not support file or dir name include: \/:*?"<>|
func IssueCertImpl ¶
func IssueCertImpl(rootCa *x509.Certificate, rootKey *rsa.PrivateKey) (*pem.Block, *pem.Block, error)
IssueCertImpl Issue sub-certificates based on the root certificate
func LoadPublicKeyRSA ¶
LoadPublicKeyRSA Parse the public key from the public key byte stream (the key must be formatted).
func LoadRSAPrivateKeyPKCS1 ¶
func LoadRSAPrivateKeyPKCS1(priKey []byte) (*rsa.PrivateKey, error)
LoadRSAPrivateKeyPKCS1 Parse the private key from the key byte stream (the key must be formatted), using PKCS1.
func LoadRSAPrivateKeyPKCS8 ¶
func LoadRSAPrivateKeyPKCS8(priKey []byte) (*rsa.PrivateKey, error)
LoadRSAPrivateKeyPKCS8 Parse the private key from the key byte stream (the key must be formatted), using PKCS8.
func LoadRootCa ¶
func LoadRootCa(caFile string, keyFile string) (*x509.Certificate, *rsa.PrivateKey, error)
LoadRootCa load ca.
func RsaDecryptRSA ¶
func RsaDecryptRSA(cipherText []byte, myPriKey *rsa.PrivateKey) ([]byte, error)
RsaDecryptRSA RSA decryption, decrypt with your own private key
func RsaEncryptRSA ¶
RsaEncryptRSA RSA encryption, using the peer's public key encryption.
func SaveCert2File ¶
SaveCert2File Save the certificate as file.
func SignWithSha256RSA ¶
SignWithSha256RSA Digitally sign the hash value of the data with your own private key.
Types ¶
type Curve22519Ecdh ¶
type Curve22519Ecdh struct { PublicKey string PrivateKey string // contains filtered or unexported fields }
Curve22519Ecdh curve22519 ECDH.
func NewCurve22519Ecdh ¶
func NewCurve22519Ecdh() *Curve22519Ecdh
NewCurve22519Ecdh create curve22519 ecdh.
func (*Curve22519Ecdh) GenerateKeyPair ¶
func (c *Curve22519Ecdh) GenerateKeyPair() error
GenerateKeyPair Generate a public and private key pair.
func (*Curve22519Ecdh) GetPublicKey ¶
func (c *Curve22519Ecdh) GetPublicKey() string
GetPublicKey get public key.
func (*Curve22519Ecdh) GetSharedKey ¶
func (c *Curve22519Ecdh) GetSharedKey(peerPubKey string) (string, error)
GetSharedKey get shared key.