Documentation
¶
Overview ¶
Package crypto provides comprehensive cryptographic operations including symmetric encryption, asymmetric encryption, digital signatures, and key management. It supports multiple algorithms such as AES, DES, 3DES, Blowfish, Twofish, ChaCha20, Salsa20, RC4, RSA, and Ed25519.
Index ¶
- Variables
- type Decrypter
- func (d Decrypter) By3Des(c *cipher.TripleDesCipher) Decrypter
- func (d Decrypter) ByAes(c *cipher.AesCipher) Decrypter
- func (d Decrypter) ByBlowfish(c *cipher.BlowfishCipher) Decrypter
- func (d Decrypter) ByChaCha20(c *cipher.ChaCha20Cipher) Decrypter
- func (d Decrypter) ByChaCha20Poly1305(c *cipher.ChaCha20Poly1305Cipher) Decrypter
- func (d Decrypter) ByDes(c *cipher.DesCipher) Decrypter
- func (d Decrypter) ByRc4(c *cipher.Rc4Cipher) Decrypter
- func (d Decrypter) ByRsa(kp *keypair.RsaKeyPair) Decrypter
- func (d Decrypter) BySalsa20(c *cipher.Salsa20Cipher) Decrypter
- func (d Decrypter) BySm2(kp *keypair.Sm2KeyPair) Decrypter
- func (d Decrypter) BySm4(c *cipher.Sm4Cipher) Decrypter
- func (d Decrypter) ByTea(c *cipher.TeaCipher) Decrypter
- func (d Decrypter) ByTwofish(c *cipher.TwofishCipher) Decrypter
- func (d Decrypter) ByXtea(c *cipher.XteaCipher) Decrypter
- func (d Decrypter) FromBase64Bytes(b []byte) Decrypter
- func (d Decrypter) FromBase64File(f fs.File) Decrypter
- func (d Decrypter) FromBase64String(s string) Decrypter
- func (d Decrypter) FromHexBytes(b []byte) Decrypter
- func (d Decrypter) FromHexFile(f fs.File) Decrypter
- func (d Decrypter) FromHexString(s string) Decrypter
- func (d Decrypter) FromRawBytes(b []byte) Decrypter
- func (d Decrypter) FromRawFile(f fs.File) Decrypter
- func (d Decrypter) FromRawString(s string) Decrypter
- func (d Decrypter) ToBytes() []byte
- func (d Decrypter) ToString() string
- type Encrypter
- func (e Encrypter) By3Des(c *cipher.TripleDesCipher) Encrypter
- func (e Encrypter) ByAes(c *cipher.AesCipher) Encrypter
- func (e Encrypter) ByBlowfish(c *cipher.BlowfishCipher) Encrypter
- func (e Encrypter) ByChaCha20(c *cipher.ChaCha20Cipher) Encrypter
- func (e Encrypter) ByChaCha20Poly1305(c *cipher.ChaCha20Poly1305Cipher) Encrypter
- func (e Encrypter) ByDes(c *cipher.DesCipher) Encrypter
- func (e Encrypter) ByRc4(c *cipher.Rc4Cipher) Encrypter
- func (e Encrypter) ByRsa(kp *keypair.RsaKeyPair) Encrypter
- func (e Encrypter) BySalsa20(c *cipher.Salsa20Cipher) Encrypter
- func (e Encrypter) BySm2(kp *keypair.Sm2KeyPair) Encrypter
- func (e Encrypter) BySm4(c *cipher.Sm4Cipher) Encrypter
- func (e Encrypter) ByTea(c *cipher.TeaCipher) Encrypter
- func (e Encrypter) ByTwofish(c *cipher.TwofishCipher) Encrypter
- func (e Encrypter) ByXtea(c *cipher.XteaCipher) Encrypter
- func (e Encrypter) FromBytes(b []byte) Encrypter
- func (e Encrypter) FromFile(f fs.File) Encrypter
- func (e Encrypter) FromString(s string) Encrypter
- func (e Encrypter) ToBase64Bytes() []byte
- func (e Encrypter) ToBase64String() string
- func (e Encrypter) ToHexBytes() []byte
- func (e Encrypter) ToHexString() string
- func (e Encrypter) ToRawBytes() []byte
- func (e Encrypter) ToRawString() string
- type Signer
- func (s Signer) ByEd25519(kp *keypair.Ed25519KeyPair) Signer
- func (s Signer) ByRsa(kp *keypair.RsaKeyPair) Signer
- func (s Signer) BySm2(kp *keypair.Sm2KeyPair) Signer
- func (s Signer) FromBytes(b []byte) Signer
- func (s Signer) FromFile(f fs.File) Signer
- func (s Signer) FromString(str string) Signer
- func (s Signer) ToBase64Bytes() []byte
- func (s Signer) ToBase64String() string
- func (s Signer) ToHexBytes() []byte
- func (s Signer) ToHexString() string
- func (s Signer) ToRawBytes() []byte
- func (s Signer) ToRawString() string
- type Verifier
- func (v Verifier) ByEd25519(kp *keypair.Ed25519KeyPair) Verifier
- func (v Verifier) ByRsa(kp *keypair.RsaKeyPair) Verifier
- func (v Verifier) BySm2(kp *keypair.Sm2KeyPair) Verifier
- func (v Verifier) FromBytes(b []byte) Verifier
- func (v Verifier) FromFile(f fs.File) Verifier
- func (v Verifier) FromString(s string) Verifier
- func (v Verifier) ToBool() bool
- func (v Verifier) WithBase64Sign(s []byte) Verifier
- func (v Verifier) WithHexSign(s []byte) Verifier
- func (v Verifier) WithRawSign(s []byte) Verifier
Constants ¶
This section is empty.
Variables ¶
var BufferSize = 4096
BufferSize buffer size for streaming (64KB is a good balance)
Functions ¶
This section is empty.
Types ¶
type Decrypter ¶
type Decrypter struct {
Error error
// contains filtered or unexported fields
}
Decrypter defines a Decrypter struct.
func (Decrypter) By3Des ¶
func (d Decrypter) By3Des(c *cipher.TripleDesCipher) Decrypter
By3Des decrypts by triple des.
func (Decrypter) ByAes ¶
ByAes decrypts by aes.
func (Decrypter) ByBlowfish ¶
func (d Decrypter) ByBlowfish(c *cipher.BlowfishCipher) Decrypter
ByBlowfish decrypts by blowfish.
func (Decrypter) ByChaCha20 ¶ added in v1.1.2
func (d Decrypter) ByChaCha20(c *cipher.ChaCha20Cipher) Decrypter
ByChaCha20 decrypts by chacha20.
func (Decrypter) ByChaCha20Poly1305 ¶ added in v1.1.2
func (d Decrypter) ByChaCha20Poly1305(c *cipher.ChaCha20Poly1305Cipher) Decrypter
ByChaCha20Poly1305 decrypts by chacha20-poly1305.
func (Decrypter) ByDes ¶
ByDes decrypts by des.
func (Decrypter) ByRc4 ¶
ByRc4 decrypts by rc4.
func (Decrypter) ByRsa ¶
func (d Decrypter) ByRsa(kp *keypair.RsaKeyPair) Decrypter
ByRsa decrypts by rsa.
func (Decrypter) BySalsa20 ¶ added in v1.1.4
func (d Decrypter) BySalsa20(c *cipher.Salsa20Cipher) Decrypter
BySalsa20 decrypts by salsa20.
func (Decrypter) BySm2 ¶ added in v1.2.0
func (d Decrypter) BySm2(kp *keypair.Sm2KeyPair) Decrypter
BySm2 decrypts by SM2.
func (Decrypter) BySm4 ¶ added in v1.1.7
BySm4 decrypts by sm4.
func (Decrypter) ByTea ¶
ByTea decrypts by tea.
func (Decrypter) ByTwofish ¶ added in v1.1.4
func (d Decrypter) ByTwofish(c *cipher.TwofishCipher) Decrypter
ByTwofish decrypts by twofish.
func (Decrypter) ByXtea ¶ added in v1.1.6
func (d Decrypter) ByXtea(c *cipher.XteaCipher) Decrypter
ByXtea decrypts by xtea.
func (Decrypter) FromBase64Bytes ¶
FromBase64Bytes decrypts from base64 bytes.
func (Decrypter) FromBase64File ¶
FromBase64File decrypts from base64 file.
func (Decrypter) FromBase64String ¶
FromBase64String decrypts from base64 string.
func (Decrypter) FromHexBytes ¶
FromHexBytes decrypts from hex bytes.
func (Decrypter) FromHexFile ¶
FromHexFile decrypts from hex file.
func (Decrypter) FromHexString ¶
FromHexString decrypts from hex string.
func (Decrypter) FromRawBytes ¶
FromRawBytes decrypts from raw bytes.
func (Decrypter) FromRawFile ¶
FromRawFile decrypts from raw file.
func (Decrypter) FromRawString ¶
FromRawString decrypts from raw string.
type Encrypter ¶
type Encrypter struct {
Error error
// contains filtered or unexported fields
}
Encrypter defines a Encrypter struct.
func (Encrypter) By3Des ¶
func (e Encrypter) By3Des(c *cipher.TripleDesCipher) Encrypter
By3Des encrypts by triple des.
func (Encrypter) ByAes ¶
ByAes encrypts by aes.
func (Encrypter) ByBlowfish ¶
func (e Encrypter) ByBlowfish(c *cipher.BlowfishCipher) Encrypter
ByBlowfish encrypts by blowfish.
func (Encrypter) ByChaCha20 ¶ added in v1.1.2
func (e Encrypter) ByChaCha20(c *cipher.ChaCha20Cipher) Encrypter
ByChaCha20 encrypts by chacha20.
func (Encrypter) ByChaCha20Poly1305 ¶ added in v1.1.2
func (e Encrypter) ByChaCha20Poly1305(c *cipher.ChaCha20Poly1305Cipher) Encrypter
ByChaCha20Poly1305 encrypts by chacha20-poly1305.
func (Encrypter) ByDes ¶
ByDes encrypts by des.
func (Encrypter) ByRc4 ¶
ByRc4 encrypts by rc4.
func (Encrypter) ByRsa ¶
func (e Encrypter) ByRsa(kp *keypair.RsaKeyPair) Encrypter
ByRsa encrypts by rsa.
func (Encrypter) BySalsa20 ¶ added in v1.1.4
func (e Encrypter) BySalsa20(c *cipher.Salsa20Cipher) Encrypter
BySalsa20 encrypts by salsa20.
func (Encrypter) BySm2 ¶ added in v1.2.0
func (e Encrypter) BySm2(kp *keypair.Sm2KeyPair) Encrypter
BySm2 encrypts by SM2.
func (Encrypter) BySm4 ¶ added in v1.1.7
BySm4 encrypts by sm4.
func (Encrypter) ByTea ¶
ByTea encrypts by tea.
func (Encrypter) ByTwofish ¶ added in v1.1.4
func (e Encrypter) ByTwofish(c *cipher.TwofishCipher) Encrypter
ByTwofish encrypts by twofish.
func (Encrypter) ByXtea ¶ added in v1.1.6
func (e Encrypter) ByXtea(c *cipher.XteaCipher) Encrypter
ByXtea encrypts by xtea.
func (Encrypter) FromBytes ¶
FromBytes encrypts from byte slice.
func (Encrypter) FromFile ¶
FromFile encrypts from file.
func (Encrypter) FromString ¶
FromString encrypts from string.
func (Encrypter) ToBase64Bytes ¶
ToBase64Bytes outputs as base64 byte slice.
func (Encrypter) ToBase64String ¶
ToBase64String outputs as base64 string.
func (Encrypter) ToHexBytes ¶
ToHexBytes outputs as hex byte slice.
func (Encrypter) ToHexString ¶
ToHexString outputs as hex string.
func (Encrypter) ToRawBytes ¶
ToRawBytes outputs as raw byte slice.
type Signer ¶
type Signer struct {
Error error
// contains filtered or unexported fields
}
Signer defines a Signer struct.
func (Signer) ByEd25519 ¶ added in v1.1.1
func (s Signer) ByEd25519(kp *keypair.Ed25519KeyPair) Signer
ByEd25519 signs by ed25519.
func (Signer) BySm2 ¶ added in v1.2.2
func (s Signer) BySm2(kp *keypair.Sm2KeyPair) Signer
BySm2 signs by SM2.
func (Signer) FromBytes ¶
FromBytes signs from byte slice.
func (Signer) FromString ¶
FromString signs from string.
func (Signer) ToBase64Bytes ¶
ToBase64Bytes outputs as base64 byte slice.
func (Signer) ToBase64String ¶
ToBase64String outputs as base64 string.
func (Signer) ToHexBytes ¶
ToHexBytes outputs as hex byte slice.
func (Signer) ToRawBytes ¶
ToRawBytes outputs as raw byte slice.
type Verifier ¶
type Verifier struct {
Error error
// contains filtered or unexported fields
}
Verifier defines a Verifier struct.
func (Verifier) ByEd25519 ¶ added in v1.1.1
func (v Verifier) ByEd25519(kp *keypair.Ed25519KeyPair) Verifier
ByEd25519 verifies by ed25519.
func (Verifier) ByRsa ¶
func (v Verifier) ByRsa(kp *keypair.RsaKeyPair) Verifier
ByRsa verifies by rsa.
func (Verifier) BySm2 ¶ added in v1.2.2
func (v Verifier) BySm2(kp *keypair.Sm2KeyPair) Verifier
BySm2 verifies by SM2.
func (Verifier) FromBytes ¶
FromBytes verifies from byte slice.
func (Verifier) FromFile ¶ added in v1.1.1
FromFile verifies from file.
func (Verifier) FromString ¶
FromString verifies from string.
func (Verifier) ToBool ¶
ToBool returns true if verification is successful.
func (Verifier) WithBase64Sign ¶ added in v1.1.2
WithBase64Sign verifies with base64 sign.
func (Verifier) WithHexSign ¶ added in v1.1.2
WithHexSign verifies with hex sign.
Source Files
¶
- 3des.go
- aes.go
- blowfish.go
- chacha20.go
- chacha20poly1305.go
- crypto.go
- decrypter.go
- des.go
- ed25519.go
- encryper.go
- rc4.go
- rsa.go
- salsa20.go
- signer.go
- sm2.go
- sm4.go
- tea.go
- twofish.go
- verifier.go
- xtea.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package triple_des implements Triple DES encryption and decryption with streaming support.
|
Package triple_des implements Triple DES encryption and decryption with streaming support. |
|
Package aes implements AES encryption and decryption with streaming support.
|
Package aes implements AES encryption and decryption with streaming support. |
|
Package blowfish implements Blowfish encryption and decryption with streaming support.
|
Package blowfish implements Blowfish encryption and decryption with streaming support. |
|
Package chacha20 implements ChaCha20 encryption and decryption with streaming support.
|
Package chacha20 implements ChaCha20 encryption and decryption with streaming support. |
|
Package chacha20poly1305 implements ChaCha20-Poly1305 authenticated encryption and decryption with streaming support.
|
Package chacha20poly1305 implements ChaCha20-Poly1305 authenticated encryption and decryption with streaming support. |
|
Package cipher provides cryptographic cipher configuration and base functionality.
|
Package cipher provides cryptographic cipher configuration and base functionality. |
|
Package des implements DES encryption and decryption with streaming support.
|
Package des implements DES encryption and decryption with streaming support. |
|
Package ed25519 implements ED25519 digital signature generation and verification with streaming support.
|
Package ed25519 implements ED25519 digital signature generation and verification with streaming support. |
|
internal
|
|
|
Package keypair provides cryptographic key pair management for multiple algorithms.
|
Package keypair provides cryptographic key pair management for multiple algorithms. |
|
Package rc4 implements RC4 encryption and decryption with streaming support
|
Package rc4 implements RC4 encryption and decryption with streaming support |
|
Package rsa implements RSA encryption, decryption, signing, and verification with streaming support.
|
Package rsa implements RSA encryption, decryption, signing, and verification with streaming support. |
|
Package salsa20 implements Salsa20 encryption and decryption with streaming support.
|
Package salsa20 implements Salsa20 encryption and decryption with streaming support. |
|
Package sm2 implements SM2 public key encryption, decryption, signing and verification with optional streaming helpers.
|
Package sm2 implements SM2 public key encryption, decryption, signing and verification with optional streaming helpers. |
|
Package sm4 implements SM4 encryption and decryption with streaming support.
|
Package sm4 implements SM4 encryption and decryption with streaming support. |
|
Package tea implements TEA encryption and decryption with streaming support.
|
Package tea implements TEA encryption and decryption with streaming support. |
|
Package twofish implements Twofish encryption and decryption with streaming support.
|
Package twofish implements Twofish encryption and decryption with streaming support. |
|
Package xtea implements XTEA encryption and decryption with streaming support.
|
Package xtea implements XTEA encryption and decryption with streaming support. |