Documentation ¶
Overview ¶
Package designed with functions to aid in creating, packaging, and unpackaging CipherCord messages.
Index ¶
- Constants
- Variables
- func Decrypt(s string, key32 string) (string, error)
- func Encode(msg EncryptedMessage) (string, error)
- func Encrypt(s string, key32 string) (string, error)
- func Hash32(s string) string
- func Package(umsg UnencryptedMessage) (string, error)
- type EncryptedMessage
- type UnencryptedMessage
Constants ¶
const EncryptionType string = "aes-256/gcm/b64r"
Advanced Encryption Standard (256-bit) / Galois/Counter Mode / Base64 (RAW)
const HashingType string = "sha-256/b64r/:32"
Secure Hash Algorithm (256-bit) / Base64 (RAW) / Cut 32
const Version = "1"
The major API version number.
Variables ¶
var ErrTooSmall = fmt.Errorf("ciphercord: cipher text is smaller than the nonce size")
Cipher text is smaller than the nonce size.
var ErrUnmatched error = fmt.Errorf("ciphercord: one or more unmatched fields")
Not a serious error message, this usually means either the key doesn't match or the message was packaged with a different client.
Functions ¶
func Encode ¶
func Encode(msg EncryptedMessage) (string, error)
Encodes an EncryptedMessage into a plain text string.
func Hash32 ¶
Takes string and hashes it to be 32 characters. This is how the other functions convert key to key32
func Package ¶
func Package(umsg UnencryptedMessage) (string, error)
Packages up an UnencryptedMessage to string to be ready for sending.
Types ¶
type EncryptedMessage ¶
type EncryptedMessage struct { Key string `json:"key"` // Hash of key32. Version string `json:"version"` // Unencrypted API version. Encryption string `json:"encryption"` // Unencrypted encryption type. Hashing string `json:"hashing"` // Unencrypted hashing type. Room string `json:"room"` // Unencrypted room name. Content string `json:"content"` // Encrypted message content. Author string `json:"author"` // Encrypted nickname of author. }
A package of encrypted data that is ready to be sent out in the world.
func Decode ¶
func Decode(s string) (EncryptedMessage, error)
Decodes a plain text string back into an EncryptedMessage.
func EncryptMessage ¶
func EncryptMessage(umsg UnencryptedMessage) (EncryptedMessage, error)
Converts an UnencryptedMessage into an EncryptedMessage.
type UnencryptedMessage ¶
type UnencryptedMessage struct { Key string // Secret password in plain text Room string // Room name Content string // Message content Author string // Author's nickname Version string // *API version number }
UnencryptedMessage represents a package of unencrypted information that will later be encrypted. Nothing in this struct will ever be sent over the wire.
The * indicates that this field has a preassigned value at the packaging step. It is only useful after decryption.
func DecryptMessage ¶
func DecryptMessage(emsg EncryptedMessage, key string) (UnencryptedMessage, error)
Converts an EncryptedMessage into an UnencryptedMessage.
func DecryptMessageUnstable ¶
func DecryptMessageUnstable(emsg EncryptedMessage, key string) (UnencryptedMessage, error)
The same as DecryptMessage but it assumes everything matches up. It doesn't check to see if encryption types, hashing types, or keys match up. Will not return ErrUnmatched.