xcrypto

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2025 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const ShortChar = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

Variables

This section is empty.

Functions

func AesCbcDecrypt added in v1.0.4

func AesCbcDecrypt(encrypted, key []byte) []byte

aes cbc解密

func AesCbcEncrypt added in v1.0.4

func AesCbcEncrypt(data, key []byte) []byte

aes cbc加密

func AesEcbDecrypt added in v1.0.4

func AesEcbDecrypt(encrypted, key []byte) []byte

aes ecb解密

func AesEcbEncrypt added in v1.0.4

func AesEcbEncrypt(data, key []byte) []byte

aes ecb加密

func Base62Decode

func Base62Decode(str string) int64

func Base62Encode

func Base62Encode(number int64) string

func Base64StdDecode added in v1.0.4

func Base64StdDecode(s string) string

func Base64StdEncode added in v1.0.4

func Base64StdEncode(s string) string

func Base64UrlSafeDecode added in v1.0.5

func Base64UrlSafeDecode(s string) (string, error)

Base64UrlSafeDecode Base64安全解密

func Base64UrlSafeEncode added in v1.0.5

func Base64UrlSafeEncode(s string) string

Base64UrlSafeEncode Base64安全加密

func CreateRsaKey added in v1.0.4

func CreateRsaKey(keySize int, priKeyFile, pubKeyFile string) error

创建公钥、私钥

func DecodePrivateKey added in v1.0.5

func DecodePrivateKey(pemContent []byte) (privateKey *rsa.PrivateKey, err error)

pemContent=私钥内容

func DecodePublicKey added in v1.0.5

func DecodePublicKey(pemContent []byte) (publicKey *rsa.PublicKey, err error)

pemContent=公钥内容

func DecryptDESECB4Base64

func DecryptDESECB4Base64(src, key string) string

des ECB hex解密: src := xcrypto.DecryptDESECB4Base64(xcrypto.EncryptDESECB2Base64("hello'!@123", "basesoft"),"basesoft")

func DecryptDESECB4Hex

func DecryptDESECB4Hex(src, key string) string

des ECB hex解密: src := xcrypto.DecryptDESECB4Hex(xcrypto.EncryptDESECB2Hex("123456", "basesoft"),"basesoft")

func EncryptDESECB2Base64

func EncryptDESECB2Base64(src, key string) string

des ECB base64加密:xcrypto.EncryptDESECB2Base64("密码", "basesoft")

func EncryptDESECB2Hex

func EncryptDESECB2Hex(src, key string) string

des ECB hex加密

func GetAesKey added in v1.0.4

func GetAesKey(key []byte) []byte

通过内容生成16位长度的aes key

func GetDesKey added in v1.0.4

func GetDesKey(key []byte) []byte

通过内容生成8位长度的des key

func HmacMd5 added in v1.0.4

func HmacMd5(dataStr, key string) string

func HmacSHA256 added in v1.0.5

func HmacSHA256(data, key string) string

func HmacSHA256ForByte added in v1.0.5

func HmacSHA256ForByte(data, key []byte) []byte

func HmacSha1 added in v1.0.4

func HmacSha1(dataStr, key string) string

func HmacSha256V1 added in v1.0.4

func HmacSha256V1(source, secret string) string

HmacSha256V1 HmacSHA256加密算法

func HmacSha512 added in v1.0.4

func HmacSha512(dataStr, key string) string

func HmacSha2562Byte added in v1.0.4

func HmacSha2562Byte(stringToSign string, secret string) []byte

func MD5 added in v1.0.5

func MD5(s string) string

func Md5To16 added in v1.0.5

func Md5To16(s string) string

func MysqlAesDecrypt added in v1.0.5

func MysqlAesDecrypt(src, key string) string

解密,对应mysql功能: SELECT AES_DECRYPT(from_base64("irigEC0Ta0t8Bms/KO+Ocw=="), "abc123key")

func MysqlAesEncrypt added in v1.0.5

func MysqlAesEncrypt(src, key string) string

加密,对应mysql功能: SELECT to_base64(AES_ENCRYPT("helloworld", "abc123key"));

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func Pkcs7Padding added in v1.0.4

func Pkcs7Padding(origData []byte, blockSize int) []byte

func Pkcs7UnPadding added in v1.0.4

func Pkcs7UnPadding(origData []byte) []byte

func RsaContent2PrivateKey added in v1.0.5

func RsaContent2PrivateKey(privateKeyContent string) (privateKey string)

rsa私钥内容

func RsaContent2PublicKey added in v1.0.5

func RsaContent2PublicKey(publicKeyContent string) (publicKey string)

rsa公钥内容

func RsaDecrypt added in v1.0.4

func RsaDecrypt(data []byte, privateKeyFileName string) (error, []byte)

通过私钥解密

func RsaEncrypt added in v1.0.4

func RsaEncrypt(data []byte, pubKeyFileName string) (error, []byte)

通过公钥进行rsa加密

func SHA256 added in v1.0.5

func SHA256(s string) string

func Sha1

func Sha1(str string) string

func Sha1File

func Sha1File(path string) (string, error)

类似php的sha1_file()

func Sha1V1

func Sha1V1(str string) string

func Sha256ByByteV1

func Sha256ByByteV1(by []byte) string

func Sha256V1

func Sha256V1(str string) string

func Sha256V2 added in v1.0.4

func Sha256V2(str string) string

func Sha512 added in v1.0.4

func Sha512(dataStr string) string

func Sha2562Byte added in v1.0.4

func Sha2562Byte(str string) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL