Documentation
¶
Overview ¶
crypto utility pkg.
Index ¶
- Constants
- Variables
- func AesEcbDecrypt(secret []byte, s string) (string, error)
- func AesEcbEncrypt(secret []byte, plain string) (string, error)
- func LoadPrivKey(content string) (*rsa.PrivateKey, error)
- func LoadPubKey(content string) (*rsa.PublicKey, error)
- func MD5Hex(b []byte) string
- func MD5HexStr(b string) string
- func NewECBDecrypter(b cipher.Block) cipher.BlockMode
- func NewECBEncrypter(b cipher.Block) cipher.BlockMode
- func PKCSPadding(ciphertext []byte, blockSize int) []byte
- func PKCSTrimming(encrypt []byte) []byte
- func SHA1Hex(b []byte) string
- func SHA1HexStr(b string) string
- func SHA256Hex(b []byte) string
- func SHA256HexStr(b string) string
- func SHA512Hex(b []byte) string
- func SHA512HexStr(b string) string
- type ECBDecrypter
- type ECBEncrypter
Constants ¶
View Source
const ( // PKI X.509, public key start PubPemBegin = "-----BEGIN PUBLIC KEY-----" // PKCS8, private key start PrivPemBegin = "-----BEGIN PRIVATE KEY-----" // PKCS8, private key end PrivPemEnd = "-----END PRIVATE KEY-----" )
Variables ¶
View Source
var ( ErrDecodePemFailed = errors.New("failed to decode public key pem") ErrInvalidKey = errors.New("invalid key") )
Functions ¶
func AesEcbDecrypt ¶ added in v0.1.1
AES/ECB/PKCSPadding decode hex string and decrypt.
func AesEcbEncrypt ¶ added in v0.1.1
AES/ECB/PKCSPadding encrypt and encoded as hex string.
func LoadPrivKey ¶
func LoadPrivKey(content string) (*rsa.PrivateKey, error)
Load RSA PrivateKey from content.
Content should be PKCS8 compatible format with or without '-----BEGIN PRIVATE KEY-----' prefix and suffix.
func LoadPubKey ¶
Load RSA PublicKey from content.
Content should be X.509 compatible format with or without '-----BEGIN PUBLIC KEY-----' prefix and suffix.
func NewECBDecrypter ¶ added in v0.1.1
ECB block mode for decryption.
func NewECBEncrypter ¶ added in v0.1.1
ECB block mode for encryption.
func PKCSPadding ¶ added in v0.1.1
PKCS5/7 Padding
func SHA1HexStr ¶ added in v0.4.4
func SHA256HexStr ¶ added in v0.4.10
func SHA512HexStr ¶ added in v0.4.10
Types ¶
type ECBDecrypter ¶ added in v0.1.1
type ECBDecrypter ecb
func (*ECBDecrypter) BlockSize ¶ added in v0.1.1
func (ec *ECBDecrypter) BlockSize() int
func (*ECBDecrypter) CryptBlocks ¶ added in v0.1.1
func (ec *ECBDecrypter) CryptBlocks(dst, src []byte)
type ECBEncrypter ¶ added in v0.1.1
type ECBEncrypter ecb
func (*ECBEncrypter) BlockSize ¶ added in v0.1.1
func (ec *ECBEncrypter) BlockSize() int
func (*ECBEncrypter) CryptBlocks ¶ added in v0.1.1
func (ec *ECBEncrypter) CryptBlocks(dst, src []byte)
Click to show internal directories.
Click to hide internal directories.