Documentation ¶
Index ¶
- Constants
- func AESDecrypt(s []byte, key []byte, iv []byte) ([]byte, error)
- func AESDecryptString(s string, key []byte, iv []byte) (string, error)
- func AESEncrypt(s []byte, key []byte, iv []byte) ([]byte, error)
- func AESEncryptString(s string, key []byte, iv []byte) (string, error)
- func DESDecrypt(s []byte, key []byte, iv []byte) ([]byte, error)
- func DESDecryptString(s string, key []byte, iv []byte) (string, error)
- func DESEncrypt(s []byte, key []byte, iv []byte) ([]byte, error)
- func DESEncryptString(s string, key []byte, iv []byte) (string, error)
- func GenerateAES128Key() []byte
- func GenerateAES192Key() []byte
- func GenerateAES256Key() []byte
- func GenerateDESKey() []byte
- func GenerateTripleDESKey() []byte
- func PKCS5Padding(ciphertext []byte) []byte
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCSTrimming(ciphertext []byte) []byte
- func RSAEncrypt(buf []byte, key []byte) ([]byte, error)
- func RSAEncryptNoPadding(buf []byte, key *rsa.PublicKey) []byte
- func RSAEncryptPKCS1v15(buf []byte, key *rsa.PublicKey) ([]byte, error)
- func RSAPublicKeyFromBytes(n []byte, e int) *rsa.PublicKey
- func RSAPublicKeyFromString(n string, e int, base int) (*rsa.PublicKey, error)
- func TripleDESDecrypt(s []byte, key []byte, iv []byte) ([]byte, error)
- func TripleDESDecryptString(s string, key []byte, iv []byte) (string, error)
- func TripleDESEncrypt(s []byte, key []byte, iv []byte) ([]byte, error)
- func TripleDESEncryptString(s string, key []byte, iv []byte) (string, error)
- type AES128Key
- type AES192Key
- type AES256Key
- type BlockReader
- func NewAESReader(r io.Reader, key []byte, iv []byte) (*BlockReader, error)
- func NewBlockReader(blockMode cipher.BlockMode, src io.Reader) *BlockReader
- func NewDESReader(r io.Reader, key []byte, iv []byte) (*BlockReader, error)
- func NewTripleDESReader(r io.Reader, key []byte, iv []byte) (*BlockReader, error)
- type BlockWriter
- func NewAESWriter(dst io.Writer, k []byte, iv []byte) (*BlockWriter, error)
- func NewBlockWriter(blockMode cipher.BlockMode, dst io.Writer) *BlockWriter
- func NewDESWriter(dst io.Writer, k []byte, iv []byte) (*BlockWriter, error)
- func NewTripleDESWriter(dst io.Writer, k []byte, iv []byte) (*BlockWriter, error)
- type DESKey
- type KeySizeError
- type ShortCiphertextSizeError
- type TripleDESKey
Constants ¶
const (
// RSA default E
RSADefaultExponent = 65537
)
Variables ¶
This section is empty.
Functions ¶
func AESDecryptString ¶
AESDecryptString
func AESEncryptString ¶
AESEncryptString
func DESDecryptString ¶
DESDecryptString
func DESEncryptString ¶
DESEncryptString
func GenerateAES128Key ¶
func GenerateAES128Key() []byte
GenerateAES128Key generate random AES128Key
func GenerateAES192Key ¶
func GenerateAES192Key() []byte
GenerateAES192Key generate random AES192Key
func GenerateAES256Key ¶
func GenerateAES256Key() []byte
GenerateAES256Key generate random AES256Key
func GenerateTripleDESKey ¶
func GenerateTripleDESKey() []byte
GenerateTripleDESKey generate random TripleDESKey
func PKCS5Padding ¶
func PKCS7Padding ¶
func PKCSTrimming ¶
func RSAEncrypt ¶
RSAEncrypt encrypt buf with PKCS1v15
func RSAEncryptNoPadding ¶
RSAEncryptNoPadding calc rsa encrypt with no padding
func RSAEncryptPKCS1v15 ¶
RSAEncryptPKCS1v15 encrypt buf with PKCS1v15
func RSAPublicKeyFromBytes ¶
RSAPublicKeyFromBytes create *rsa.PublicKey from n bytes. if e zero use 65537
func RSAPublicKeyFromString ¶
RSAPublicKeyFromString create *rsa.PublicKey from n string. if e zero use 65537 The base argument must be 0 or a value between 2 and MaxBase. For base 0, the number prefix determines the actual base: A prefix of “0b” or “0B” selects base 2, “0”, “0o” or “0O” selects base 8, and “0x” or “0X” selects base 16. Otherwise, the selected base is 10 and no prefix is accepted. For bases <= 36, lower and upper case letters are considered the same: The letters 'a' to 'z' and 'A' to 'Z' represent digit values 10 to 35. For bases > 36, the upper case letters 'A' to 'Z' represent the digit values 36 to 61. For base 0, an underscore character “_” may appear between a base prefix and an adjacent digit, and between successive digits; such underscores do not change the value of the number. Incorrect placement of underscores is reported as an error if there are no other errors. If base != 0, underscores are not recognized and act like any other character that is not a valid digit.
func TripleDESDecrypt ¶
TripleDESDecrypt
func TripleDESDecryptString ¶
TripleDESDecryptString
func TripleDESEncrypt ¶
TripleDESEncrypt
Types ¶
type BlockReader ¶
type BlockReader struct { io.ReadCloser // contains filtered or unexported fields }
BlockReader block ciphertext streaming reader
func NewAESReader ¶
NewAESReader creates and returns a new BlockReader. The key argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.
func NewBlockReader ¶
func NewBlockReader(blockMode cipher.BlockMode, src io.Reader) *BlockReader
wrap BlockReader block ciphertext streaming reader
func NewDESReader ¶
NewDESReader creates and returns a new BlockReader
func NewTripleDESReader ¶
NewTripleDESReader creates and returns a new BlockReader
func (*BlockReader) Close ¶
func (c *BlockReader) Close() error
type BlockWriter ¶
type BlockWriter struct { io.WriteCloser // contains filtered or unexported fields }
BlockWriter block ciphertext streaming writer
func NewAESWriter ¶
NewAESWriter creates and returns a new BlockWriter. The key argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.
func NewBlockWriter ¶
func NewBlockWriter(blockMode cipher.BlockMode, dst io.Writer) *BlockWriter
wrap BlockReader block ciphertext streaming writer
func NewDESWriter ¶
NewDESWriter creates and returns a new BlockWriter
func NewTripleDESWriter ¶
NewTripleDESWriter creates and returns a new BlockWriter
func (*BlockWriter) Close ¶
func (c *BlockWriter) Close() error
Note: Because it is block encryption, you need to manually call Close() when closing to write the block content of the cache
type KeySizeError ¶
type KeySizeError int
func (KeySizeError) Error ¶
func (k KeySizeError) Error() string
type ShortCiphertextSizeError ¶
type ShortCiphertextSizeError int
func (ShortCiphertextSizeError) Error ¶
func (s ShortCiphertextSizeError) Error() string