Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptFromBase64 ¶
DecryptFromBase64 decrypt base64 string data with given Cipher and returns massage
messsage, err = DecryptFromBase64(myAES, cipherString) messsage, err = DecryptFromBase64(myBox, cipherString) messsage, err = DecryptFromBase64(mySalsa20, cipherString)
func EncryptToBase64 ¶
EncryptToBase64 encrypt data with given Cipher and returns base64 string
cipherString, err = EncryptToBase64(myAES, []byte("Hello! 中国")) cipherString, err = EncryptToBase64(myBox, []byte("Hello! 中国")) cipherString, err = EncryptToBase64(mySalsa20, []byte("Hello! 中国"))
func GenerateKey ¶
func GenerateKey() (publicKey, privateKey string)
GenerateKey generates a public/private key pair for Box. the keys is encoded by base64.RawURLEncoding
Types ¶
type AES ¶
type AES struct {
// contains filtered or unexported fields
}
AES use to encrypts/decrypts message with AES-256 with CTR Mode, it implemented Cipher insterface.
type Box ¶
type Box struct {
// contains filtered or unexported fields
}
Box use to encrypts/decrypts message with nacl/box (curve25519&salsa20), it implemented Cipher insterface.
type Cipher ¶
type Cipher interface { // Encrypt encrypts the first block in src into dst. // Dst and src must overlap entirely or not at all. Encrypt([]byte) ([]byte, error) // Decrypt decrypts the first block in src into dst. // Dst and src must overlap entirely or not at all. Decrypt([]byte) ([]byte, error) }
Cipher is using for EncryptToBase64 and DecryptFromBase64
type Salsa20 ¶
type Salsa20 struct {
// contains filtered or unexported fields
}
Salsa20 use to encrypts/decrypts message with salsa20, it implemented Cipher insterface.
func NewSalsa20 ¶
NewSalsa20 returns Salsa20 instance.
Click to show internal directories.
Click to hide internal directories.