Documentation ¶
Index ¶
- Constants
- func PKCS7Padding(buf []byte, blockSize int) []byte
- func PKCS7Trimming(buf []byte) ([]byte, error)
- 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)
- type AES
- type AES128Key
- type AES192Key
- type AES256Key
- type DES
- type DESKey
Constants ¶
const (
// RSA default E
RSADefaultExponent = 65537
)
Variables ¶
This section is empty.
Functions ¶
func PKCS7Padding ¶
PKCS7Padding padding bytes with PKCS7
func PKCS7Trimming ¶
PKCS7Trimming trimming bytes with PKCS7
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.
Types ¶
type AES ¶
type AES struct {
// contains filtered or unexported fields
}
func (*AES) CBCDecrypt ¶
CBCDecrypt decrypt with CBC cipher. trimming with PKCS7
func (*AES) CBCEncrypt ¶
CBCEncrypt encrypt with CBC cipher. padding with PKCS7
func (*AES) CFBDecrypt ¶
CFBDecrypt decrypt with CFB cipher
func (*AES) CFBEncrypt ¶
CFBEncrypt encrypt with CFB cipher
type AES128Key ¶
type AES128Key [16]byte
func GenerateAES128Key ¶
func GenerateAES128Key() (ret AES128Key)
GenerateAES128Key generate random AES128Key
type AES192Key ¶
type AES192Key [24]byte
func GenerateAES192Key ¶
func GenerateAES192Key() (ret AES192Key)
GenerateAES192Key generate random AES192Key
type AES256Key ¶
type AES256Key [32]byte
func GenerateAES256Key ¶
func GenerateAES256Key() (ret AES256Key)
GenerateAES256Key generate random AES256Key
type DES ¶
type DES struct {
// contains filtered or unexported fields
}
func (*DES) CBCDecrypt ¶
CBCDecrypt decrypt with CBC cipher. trimming with PKCS7
func (*DES) CBCEncrypt ¶
CBCEncrypt encrypt with CBC cipher. padding with PKCS7
func (*DES) CFBDecrypt ¶
CFBDecrypt decrypt with CFB cipher
func (*DES) CFBEncrypt ¶
CFBEncrypt encrypt with CFB cipher