utils

package
v4.10.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2020 License: MIT Imports: 22 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptFile

func DecryptFile(cipherKey string, contentLenEnc int64, reader io.Reader, w io.WriteCloser)

func DecryptString

func DecryptString(cipherKey string, message string, useRandomInitializationVector bool) (
	retVal interface{}, err error)

DecryptString decodes encrypted string using the cipherKey

It accepts the following parameters: cipherKey: cipher key to use to decrypt. message: to encrypted. useRandomInitializationVector: if true the IV is random and is prepended to the text. The IV is extracted and then the cipher is decoded.

returns the unencoded encrypted string, error if any.

func EncodeJSONAsPathComponent

func EncodeJSONAsPathComponent(jsonBytes string) string

encodeJSONAsPathComponent properly encodes serialized JSON for placement within a URI path

func EncryptCipherKey

func EncryptCipherKey(cipherKey string) []byte

EncryptCipherKey creates the 256 bit hex of the cipher key

It accepts the following parameters: cipherKey: cipher key to use to decrypt.

returns the 256 bit hex of the cipher key.

func EncryptFile

func EncryptFile(cipherKey string, iv []byte, filePart io.Writer, file *os.File)

func EncryptString

func EncryptString(cipherKey string, message string, useRandomInitializationVector bool) string

EncryptString creates the base64 encoded encrypted string using the cipherKey. It accepts the following parameters: cipherKey: cipher key to use to encrypt. message: to encrypted. useRandomInitializationVector: if true the IV is random and is sent along with the message

returns the base64 encoded encrypted string.

func GetHmacSha256

func GetHmacSha256(secretKey string, input string) string

getHmacSha256 creates the cipher key hashed against SHA256. It accepts the following parameters: secretKey: the secret key. input: input to hash.

returns the hash.

func JoinChannels

func JoinChannels(channels []string) []byte

JoinChannels encodes and joins channels

func PamEncode

func PamEncode(value string) string

func PreparePamParams

func PreparePamParams(params *url.Values) string

func Serialize

func Serialize(msg interface{}) ([]byte, error)

func SerializeAndEncrypt

func SerializeAndEncrypt(msg interface{}, cipherKey string, serialize bool, useRandomInitializationVector bool) (string, error)

func SerializeEncryptAndSerialize

func SerializeEncryptAndSerialize(msg interface{}, cipherKey string, serialize bool, useRandomInitializationVector bool) (string, error)

func TestComplexClassDecryption

func TestComplexClassDecryption(t *testing.T)

TestComplexClassDecryption tests the complex struct decryption. Decrypted string should match Bc846Ri5HK1ixqP/dzAyZq23Z/NBlcPn2UX8h38xTGINs72yF5gtU0t9fFEMxjY+DmezWt0nG7eN7RABrj697tK1nooVHYIxgDLMsjMTw5N0K+rUM823n7LcHfEoXaX8oH2E6zkg6iK5pmT8nlh6LF6Bw1G5zkluT8oTjnbFJcpEvTyT2ZKzcqptgYsE9XZiqgBMEfYqwphDzmOv+TjHkJai+paV0rzFxIfVK8KHCA14z+1kKDMPghlmzx2tUmmbQb04hjhvgDvvi3tknytYVqJo1L5jZkAZTVXRfed7wq+L+1V824c9AwVsG9iCv15/Jemjjfzk07MXawk+hjmQvjQDWLS/ww3vwkNXiuJITbVCPOBADwJhBnFqkkb/Hd8LaKwyFhWeXwoZWbqugDoYufUzJApf4Nl/4RthYoisqJIokmxiWvYeD1TuH+C457kDaEu3aJd+KdLf8k9QkmaDNqkZo9Z/BRkZ63oMna1aEBy7bSE3l/lw40dnhsMaYfYk

func TestComplexClassEncryption

func TestComplexClassEncryption(t *testing.T)

TestComplexClassEncryption tests the complex struct encryption. Encrypted string should match Bc846Ri5HK1ixqP/dzAyZq23Z/NBlcPn2UX8h38xTGINs72yF5gtU0t9fFEMxjY+DmezWt0nG7eN7RABrj697tK1nooVHYIxgDLMsjMTw5N0K+rUM823n7LcHfEoXaX8oH2E6zkg6iK5pmT8nlh6LF6Bw1G5zkluT8oTjnbFJcpEvTyT2ZKzcqptgYsE9XZiqgBMEfYqwphDzmOv+TjHkJai+paV0rzFxIfVK8KHCA14z+1kKDMPghlmzx2tUmmbQb04hjhvgDvvi3tknytYVqJo1L5jZkAZTVXRfed7wq+L+1V824c9AwVsG9iCv15/Jemjjfzk07MXawk+hjmQvjQDWLS/ww3vwkNXiuJITbVCPOBADwJhBnFqkkb/Hd8LaKwyFhWeXwoZWbqugDoYufUzJApf4Nl/4RthYoisqJIokmxiWvYeD1TuH+C457kDaEu3aJd+KdLf8k9QkmaDNqkZo9Z/BRkZ63oMna1aEBy7bSE3l/lw40dnhsMaYfYk

func URLEncode

func URLEncode(s string) string

TODO: verify the helper is used where supposed to

func UUID

func UUID() string

Generate a random uuid string

func ValueAsString

func ValueAsString(value interface{}) ([]byte, error)

PubNub - specific serializer

Types

type A

type A struct {
	I         string
	Interface *B
}

type B

type B struct {
	Value string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL