Documentation
¶
Index ¶
- func BytesToInt64(data []byte) (int64, int, error)
- func BytesToInt64FromReader(reader io.Reader) (int64, int, error)
- func BytesToInt64s(data []byte) ([]int64, error)
- func BytesToInt8s(data []byte) []int8
- func Decrypt(encryptedData []int64, IV []int8, key *NSEKey) (decryptedData []byte, err error)
- func Encrypt(data []byte, key *NSEKey) (encryptedData []int64, IV []int8, err error)
- func GenerateIV(length int, rotatedData []int8, key *NSEKey) ([]int8, error)
- func Int64ToBytes(integer int64) []byte
- func Int64sToBytes(data []int64) []byte
- func Int8sToBytes(data []int8) []byte
- type NSEKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToInt64 ¶
BytesToInt64 converts byte array into int64. It returns converted integer, bytes read and err. err != nil if and only if binary.Varint returns an error.
func BytesToInt64FromReader ¶
BytesToInt64FromReader converts few first bytes into int64. It returns converted integer, bytes read and err. err != nil if and only if binary.Varint returns an error or given reader doesn't have that many bytes to read.
func BytesToInt64s ¶
BytesToInt64s converts result of Int64sToBytes back into []int64. It returns errors.WrongDataFormatError as an error when data doesn't appear to be a result of Int64sToBytes.
func BytesToInt8s ¶
BytesToInt8s converts []byte into []int8. Every byte in the slice is treated like it would be signed.
func Decrypt ¶
Decrypt decrypts encryptedData using NSE algorithm with given IV and key derived using DeriveKey function. It returns decryptedData and err. err != nil if len(data) < 1, len(data) != len(IV).
func Encrypt ¶
Encrypt encrypts data using NSE algorithm with given key derived using DeriveKey function. It returns encryptedData, IV and err. err != nil if len(data) < 1 or if GenerateIV function returned an error.
func GenerateIV ¶
GenerateIV generates IV of given length for NSE algorithm. It returns an error if length < 1 or if crypto.rand.Read returns an error.
func Int64ToBytes ¶
Int64ToBytes converts integer into byte array. It ignores padding, result is as short as possible. First byte is length of the rest.
func Int64sToBytes ¶
Int64sToBytes converts []int64 into []byte. For each int64 in the slice there is one byte indicating how many bytes to read next and those bytes.
func Int8sToBytes ¶
Int8sToBytes converts []int8 into []byte. Every int8 in the slice is treated like it would be unsigned.