Documentation ¶
Overview ¶
Copyright (c) 2018-2019 WING All Rights Reserved.
Author : yangping Email : youhei_yp@163.com
Prismy.No | Date | Modified by. | Description ------------------------------------------------------------------- 00001 2019/05/22 yangping New version -------------------------------------------------------------------
Index ¶
- func AESDecrypt(secretkey []byte, ciphertextb64 string) (string, error)
- func AESEncrypt(secretkey, original []byte) (string, error)
- func Base64ToByte(ciphertext string) ([]byte, error)
- func ByteToBase64(original []byte) string
- func DecodeBase64(ciphertext string) (string, error)
- func DecodeJwtKeyword(keyword string) (string, string, string)
- func ECCHashSignB64(hash []byte, prikeyb64 string) (string, error)
- func ECCHashVerifyB64(hash []byte, pubkeyb64 string, rsb64 string) (bool, error)
- func EncodeB64MD5(original string) string
- func EncodeBase64(original string) string
- func EncodeJwtKeyword(uuid, pwd, subject string) string
- func EncodeMD5(original string) string
- func EncodeMD5B64(original string) string
- func GenAESKey() string
- func GenCode() string
- func GenCodeFrom(src int64) string
- func GenECCPriKey(prikey string) (*ecdsa.PrivateKey, error)
- func GenECCPriKeyB64(prikeyb64 string) (*ecdsa.PrivateKey, error)
- func GenECCPubKey(pubkey string) (*ecdsa.PublicKey, error)
- func GenECCPubKeyB64(pubkeyb64 string) (*ecdsa.PublicKey, error)
- func GenECCShareKeys(pub *ecdsa.PublicKey, priD *big.Int) (*big.Int, *big.Int)
- func GenEccShareKeysHash(prikey, pubkey string) ([]byte, error)
- func GenEccShareKeysHashB64(prikeyb64, pubkeyb64 string) ([]byte, error)
- func GenHash(src, salt string) (string, error)
- func GenJwtToken(keyword, salt string, dur time.Duration) (string, error)
- func GenLoginToken(acc, pwd string) string
- func GenNonce() string
- func GenOAuthCode(length int, randomType string) (string, error)
- func GenRSAKeys(bits int) (string, string, error)
- func GenRSFromB2BI(sign []byte) (*big.Int, *big.Int)
- func GenRandCode() string
- func GenRandCodeFrom(src int64) string
- func GenSalt() (string, error)
- func GenToken(original string) string
- func GenUUID() int64
- func GenUUIDString() string
- func HashByteThenBase64(data []byte) string
- func HashMD5(original []byte) []byte
- func HashSHA256(original []byte) []byte
- func HashSHA256Hex(original []byte) string
- func HashSHA256String(original string) []byte
- func HashThenBase64(data string) string
- func LoadRSAKey(filepath string, buffbits ...int) ([]byte, error)
- func RSA2Sign(prikey, original []byte) ([]byte, error)
- func RSA2Sign4F(prifile string, original []byte) ([]byte, error)
- func RSA2Sign4FB64(prifile string, original []byte) (string, error)
- func RSA2SignB64(prikey, original []byte) (string, error)
- func RSA2Verify(pubkey, original, signature []byte) error
- func RSA2Verify4F(pubfile string, original, signature []byte) error
- func RSADecrypt(prikey, ciphertext []byte) ([]byte, error)
- func RSADecrypt4F(prifile string, ciphertext []byte) ([]byte, error)
- func RSAEncrypt(pubkey, original []byte) ([]byte, error)
- func RSAEncrypt4F(pubfile string, original []byte) ([]byte, error)
- func RSAEncrypt4FB64(pubfile string, original []byte) (string, error)
- func RSAEncryptB64(pubkey, original []byte) (string, error)
- func RSASign(prikey, original []byte) ([]byte, error)
- func RSASign4F(prifile string, original []byte) ([]byte, error)
- func RSASign4FB64(prifile string, original []byte) (string, error)
- func RSASignB64(prikey, original []byte) (string, error)
- func RSAVerify(pubkey, original, signature []byte) error
- func RSAVerify4F(pubfile string, original, signature []byte) error
- func ToMD5Hex(input ...string) string
- func ViaJwtToken(signedToken, salt string) (string, error)
- func ViaLoginToken(acc, pwd, token string, duration int64) (bool, error)
- type Claims
- type SoleCoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AESDecrypt ¶
AESDecrypt using secret key to decrypt ciphertext
func AESEncrypt ¶
AESEncrypt using secret key to encrypt original data
func Base64ToByte ¶
ByteToBase64 decode base64 string to byte array
func ByteToBase64 ¶
ByteToBase64 encode byte array to base64 string
func DecodeBase64 ¶
DecodeBase64 decode from base64 string
func DecodeJwtKeyword ¶
EncodeJwtKeyword decode account uuid, password and subject from jwt keyword string, NOTICE THAT this method split the keyword by ';' char!
func ECCHashSignB64 ¶
ECCHashSignB64 use ECC to sign hash data to base64 string by given origin private key text
func ECCHashVerifyB64 ¶
ECCHashVerifyB64 use ECC public key and rs data to verify given hash data
func EncodeB64MD5 ¶
EncodeB64MD5 encode string to base64, and then encode by md5
func EncodeJwtKeyword ¶
EncodeJwtKeyword encode account uuid, password and subject string, NOTICE THAT this method joined the uuid, pwd and subject with ';' char!
func EncodeMD5B64 ¶
EncodeMD5B64 encode string to md5, and then encode by base64
func GenCodeFrom ¶
GenCodeFrom generate a code from given int64 data
func GenECCPriKey ¶
func GenECCPriKey(prikey string) (*ecdsa.PrivateKey, error)
GenECCPriKey generate a ECC private key by origin key text
func GenECCPriKeyB64 ¶
func GenECCPriKeyB64(prikeyb64 string) (*ecdsa.PrivateKey, error)
GenECCPriKeyB64 generate a ECC private key by base64 formated key text
func GenECCPubKey ¶
GenECCPubKey generate a ECC public key by origin key text
func GenECCPubKeyB64 ¶
GenECCPubKeyB64 generate a ECC public key by base64 formated key text
func GenECCShareKeys ¶
GenECCShareKeys generate ECC shared keys by ECC public key and private digital signature
func GenEccShareKeysHash ¶
GenEccShareKeysHash generate ECC share keys hash data by origin private and public key
func GenEccShareKeysHashB64 ¶
GenEccShareKeysHashB64 generate ECC share keys hash data by base64 formated private and public key
func GenJwtToken ¶
ObatinJwtToken generate a jwt token with keyword and salt string, the token will expired after the given duration
func GenLoginToken ¶
GenLoginToken generate a login token with account and password --------------------------------------------------------
account password |- + -| | base64 current nanosecode | | md5 base64 +------- "."---------| | base64 => token
--------------------------------------------------------
func GenNonce ¶ added in v1.0.13
func GenNonce() string
GenNonce generate a random num than to string
func GenOAuthCode ¶
GenOAuthCode generate a random OAuth code
func GenRSAKeys ¶
GenRSAKeys generate RSA private and public keys in PKCS#1, ASN.1 DER form, and limit bits length of key cert.
func GenRSFromB2BI ¶
GenRSFromB2BI generate R and S from sign data
func GenRandCode ¶
func GenRandCode() string
GenRandCode generate a code by using current nanosecond and append random suffix
func GenRandCodeFrom ¶
GenRandCodeFrom generate a code from given int64 data and append random suffix
func HashByteThenBase64 ¶
HashByteThenBase64 hash byte array by sha256 and than to base64 string
func HashSHA256Hex ¶ added in v1.0.15
HashSHA256Hex hash byte array by sha256 then encode to hex
func HashSHA256String ¶
HashSHA256String hash string by sha256
func HashThenBase64 ¶
HashThenBase64 hash string by sha256 and than to base64 string
func LoadRSAKey ¶
LoadRSAKey load RSA or RSA2 private or public key content from the given pem file, and if input the beffer size, the bufbits must larger than pem file size by call GenRSAKeys to set bits.
func RSA2Sign ¶ added in v1.0.14
RSA2Sign using RSA2 private key to make digital signature, the private key in PKCS#8, ASN.1 DER form.
func RSA2Sign4F ¶ added in v1.0.14
RSA2Sign4F using RSA2 private key file to make digital signature. the private key in PKCS#8, ASN.1 DER form.
func RSA2Sign4FB64 ¶ added in v1.0.14
RSA2Sign4FB64 using RSA2 private key file to make digital signature, then format to base64 form, the private key in PKCS#8, ASN.1 DER form.
func RSA2SignB64 ¶ added in v1.0.14
RSA2SignB64 using RSA2 private key file to make digital signature, then format to base64 form, the private key in PKCS#8, ASN.1 DER form.
func RSA2Verify ¶ added in v1.0.14
RSA2Verify using RSA2 public key to verify signatured data.
func RSA2Verify4F ¶ added in v1.0.14
RSA2Verify4F using RSA2 public key to verify signatured data.
func RSADecrypt ¶
RSADecrypt using RSA private key to decrypt ciphertext.
func RSADecrypt4F ¶ added in v1.0.14
RSADecrypt4F using RSA private key file to decrypt ciphertext.
func RSAEncrypt ¶
RSAEncrypt using RSA public key to encrypt original data.
func RSAEncrypt4F ¶ added in v1.0.14
RSAEncrypt4F using RSA public key file to encrypt original data.
func RSAEncrypt4FB64 ¶ added in v1.0.14
RSAEncrypt4FB64 using RSA public key file to encrypt original data, then format to base64 form.
func RSAEncryptB64 ¶ added in v1.0.14
RSAEncryptB64 using RSA public key to encrypt original data, then format to base64 form.
func RSASign ¶
RSASign using RSA private key to make digital signature, the private key in PKCS#1, ASN.1 DER form.
func RSASign4F ¶ added in v1.0.14
RSASign4F using RSA private key file to make digital signature, the private key in PKCS#1, ASN.1 DER form.
func RSASign4FB64 ¶ added in v1.0.14
RSASign4FB64 using RSA private key file to make digital signature, then format to base64 form, the private key in PKCS#1, ASN.1 DER form.
func RSASignB64 ¶ added in v1.0.14
RSASignB64 using RSA private key to make digital signature, then format to base64 form, the private key in PKCS#1, ASN.1 DER form.
func RSAVerify4F ¶ added in v1.0.14
RSAVerify4F using RSA public key file to verify signatured data.
func ToMD5Hex ¶
ToMd5Hex encode multi-input to md5 one string, it same as EncodeMD5 when input only one string.
func ViaJwtToken ¶
ViaLoginToken verify the encoded jwt token witch salt string
func ViaLoginToken ¶
ViaLoginToken verify login token --------------------------------------------------------
token => base64 | +------- "."---------| md5 base64 | | base64 current nanosecode | |- + -| account password
--------------------------------------------------------
Types ¶
type Claims ¶
type Claims struct { Keyword string `json:"keyword"` jwt.StandardClaims }
Claims jwt claims data
type SoleCoder ¶
type SoleCoder struct {
// contains filtered or unexported fields
}
SoleCoder random coder to generate unique number code
func NewSoleCoder ¶
NewSoleCoder create SoleCoder and init with exist codes