Documentation ¶
Index ¶
- Variables
- type Bytes
- func FromBase64(base64String string) (Bytes, error)
- func FromBytes(bs []byte) Bytes
- func FromHex(hexString string) (Bytes, error)
- func FromString(str string) Bytes
- func GenerateBytes(n int) (Bytes, error)
- func PaddingNone(bs Bytes, blockSize int) Bytes
- func PaddingPKCS5(bs Bytes, blockSize int) Bytes
- func PaddingPKCS7(bs Bytes, blockSize int) Bytes
- func PaddingZero(bs Bytes, blockSize int) Bytes
- func UnPaddingNone(bs Bytes, blockSize int) (Bytes, error)
- func UnPaddingPKCS5(bs Bytes, blockSize int) (Bytes, error)
- func UnPaddingPKCS7(bs Bytes, blockSize int) (Bytes, error)
- func UnPaddingZero(bs Bytes, blockSize int) (Bytes, error)
- type Padding
- type UnPadding
Constants ¶
This section is empty.
Variables ¶
var ( // FileFlag is the flag of file. FileFlag = os.O_CREATE | os.O_APPEND | os.O_WRONLY // FileMode is the mode of file. FileMode os.FileMode = 0644 )
var ( // Base64 is the encoding of base64. Base64 = base64.StdEncoding )
Functions ¶
This section is empty.
Types ¶
type Bytes ¶
type Bytes []byte
Bytes is an alias of []byte.
func FromBase64 ¶ added in v0.3.2
FromBase64 creates a new Bytes from base64 string.
func FromString ¶ added in v0.3.2
FromString creates a new Bytes from string.
func GenerateBytes ¶ added in v0.3.2
GenerateBytes generates a byte slice filled with random byte. It usually used to generate an iv and install iv to crypted data. For example, you use this method to generate a byte slice and pass it to encrypter as iv. After encrypting, you append this iv slice encoded to hex or base64 to crypted slice as they are one part. When you need to decrypt data, parse iv from the "crypted" slice including raw-crypted slice and iv slice first. Then you can pass this iv to decrypter and decrypt data as usual. However, you should know that the crypted data of the same plain data will be different every time because of different ivs.
func PaddingNone ¶
PaddingNone won't padding anything to bs.
func PaddingPKCS5 ¶
PaddingPKCS5 paddings bs using pkcs5.
func PaddingPKCS7 ¶
PaddingPKCS7 paddings bs using pkcs7.
func UnPaddingNone ¶
UnPaddingNone won't unPadding anything from bs.
func UnPaddingPKCS5 ¶
UnPaddingPKCS5 unPaddings bs using pkcs5.
func UnPaddingPKCS7 ¶
UnPaddingPKCS7 unPaddings bs using pkcs7.
func UnPaddingZero ¶
UnPaddingZero unPaddings zero from bs.