Documentation ¶
Index ¶
- Variables
- func AesDecrypt(crypted, key []byte) ([]byte, error)
- func AesEcbDecrypt(crypted, key []byte) ([]byte, error)
- func AesEcbEncrypt(origData, key []byte) ([]byte, error)
- func AesEncrypt(origData, key []byte) ([]byte, error)
- func Base64Decode(src []byte) (out []byte)
- func Base64DecodeString(src string) (out string)
- func Base64Encode(src []byte) []byte
- func Base64EncodeString(src string) (out string)
- func DesDecrypt(crypted, key []byte) ([]byte, error)
- func DesEncrypt(origData, key []byte) ([]byte, error)
- func Hash(in []byte, hash crypto.Hash) (out []byte)
- func HashString(in string, hash crypto.Hash) (out string)
- func Hmac(origin, key []byte, hash crypto.Hash) []byte
- func Md5(in []byte) (out []byte)
- func Md5String(in string) (out string)
- func NewECBDecrypter(b cipher.Block) cipher.BlockMode
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func RsaPriDecrypt(origin, priKey []byte) (data []byte, err error)
- func RsaPriEncrypt(origin, priKey []byte) (data []byte, err error)
- func RsaPubDecrypt(origin, pubKey []byte) (data []byte, err error)
- func RsaPubEncrypt(origin, pubKey []byte) (data []byte, err error)
- func RsaSign(origin, priKey []byte, hash crypto.Hash) ([]byte, error)
- func RsaVerify(origin, sign, pubKey []byte, hash crypto.Hash) error
- func Sha256(in string) string
- func ZeroUnPadding(origData []byte) []byte
Constants ¶
This section is empty.
Variables ¶
View Source
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") ErrPublicKey = errors.New("get public key error") ErrPrivateKey = errors.New("get private key error") )
below code from github.com/qyxing/ostar
Functions ¶
func AesDecrypt ¶
func AesEcbDecrypt ¶
func AesEcbEncrypt ¶
////////////////////////////////////////////////////////////// example: data, err := aes.AesEncrypt([]byte(str), []byte(AES_KEY))
if err != nil { fmt.Println(err) }
hexdata := hex.EncodeToString(data) fmt.Println(hex.EncodeToString(data)) data, err = hex.DecodeString(hexdata)
if err != nil { fmt.Println(err) }
fmt.Println(string(data))
func AesEncrypt ¶
AES-128。key长度:16, 24, 32 bytes 对应 AES-128, AES-192, AES-256
func Base64Decode ¶
func Base64DecodeString ¶
在go中, 如果解码的字符串缺少最后的=号, 将不能解码, 所以先填补缺少的=
func Base64Encode ¶
func Base64EncodeString ¶
func DesDecrypt ¶
func DesEncrypt ¶
func NewECBDecrypter ¶
NewECBDecrypter returns a BlockMode which decrypts in electronic code book mode, using the given Block.
func PKCS5Padding ¶
func RsaPriDecrypt ¶
func RsaPriEncrypt ¶
func RsaPubDecrypt ¶
func RsaPubEncrypt ¶
func ZeroUnPadding ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.