Documentation ¶
Index ¶
- func AesGcmDecrypt(key, ciphertext, additionalData []byte) (plaintext []byte, err error)
- func AesGcmDecryptWithNonce(key, ciphertext, nonce, additionalData []byte) (plaintext []byte, err error)
- func AesGcmEncrypt(key, plaintext, additionalData []byte) (ciphertext []byte, err error)
- func AesGcmEncryptWithNonce(key, plaintext, additionalData []byte) (ciphertext, nonce []byte, err error)
- func DecodeString(data string, encodedType Encode) ([]byte, error)
- func EncodeToString(data []byte, encodeType Encode) (string, error)
- func GenRsaKey(bits int) ([]byte, []byte, error)
- func GenerateAes256Key() ([]byte, error)
- func ParsePrivateKey(privateKeyDecoded []byte, keyType Secret) (*rsa.PrivateKey, error)
- func PrefixAppend000Length(b []byte) ([]byte, error)
- func PrefixUnAppend000Length(b []byte) (under, remains []byte, err error)
- type Encode
- type RSACrypt
- type RSASecret
- type Secret
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AesGcmDecrypt ¶
AesGcmDecrypt similar to AesGcmDecryptWithNonce, but ciphertext is nonce-contained.
func AesGcmDecryptWithNonce ¶
func AesGcmDecryptWithNonce(key, ciphertext, nonce, additionalData []byte) (plaintext []byte, err error)
AesGcmDecryptWithNonce takes an decryption key, a ciphertext and the corresponding nonce and decrypts it with AES256 in GCM mode. Returns the plaintext string.
func AesGcmEncrypt ¶
AesGcmEncrypt similar with AesGcmEncryptWithNonce, return nonce-contained ciphertext. Use AesGcmDecrypt to decrypt.
func AesGcmEncryptWithNonce ¶
func AesGcmEncryptWithNonce(key, plaintext, additionalData []byte) (ciphertext, nonce []byte, err error)
AesGcmEncryptWithNonce takes an encryption key and a plaintext string and encrypts it with AES256 in GCM mode, which provides authenticated encryption. Returns the ciphertext and the used nonce.
func DecodeString ¶
DecodeString decodes string data to bytes in designed encoded type
func EncodeToString ¶
EncodeToString encodes data to string with encode type
func GenerateAes256Key ¶
GenerateAes256Key generate 256-bit aes symmetric key.
func ParsePrivateKey ¶
func ParsePrivateKey(privateKeyDecoded []byte, keyType Secret) (*rsa.PrivateKey, error)
ParsePrivateKey parses private key bytes to rsa privateKey
func PrefixAppend000Length ¶
PrefixAppend000Length max byte length is 999. []byte(b) -> 000[]byte(b)
func PrefixUnAppend000Length ¶
PrefixUnAppend000Length 000[]byte(b)[]byte(a) -> []byte(b), []byte(a)
Types ¶
type RSACrypt ¶
type RSACrypt struct {
// contains filtered or unexported fields
}
func NewRSACrypt ¶
NewRSACrypt init with the RSA secret info