opaque

package module
v0.0.0-...-0c01d37 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: Apache-2.0 Imports: 3 Imported by: 6

README

StreamingFast Opaque library

reference License

Encrypt plaintexts for simple obfuscation, like database cursors. It is used in StramingFast.

Usage

Encode a proto message into an opaque element:

	cursor := pb.Cursor{Id: "123"}
	payload, err := proto.Marshal(&cursor)
	if err != nil { panic(err) }

	out := opaque.Encode(payload)
    // out == "xE77fJ_z6Z7UXwyx-e0kWqTtdc4yRR8vAEnvaUQSx96y"

Decode opaque element into a proto message:

	payload, err := opaque.Decode("xE77fJ_z6Z7UXwyx-e0kWqTtdc4yRR8vAEnvaUQSx96y")
	if err != nil { panic(fmt.Errorf("invalid cursor: %w", err)) }

	cursor := pb.Cursor{}
    err := proto.Unmarshal(payload, &cursor)
	if err != nil { panic(err) }

    // out == pb.Cursor{Id: "123"}

Contributing

Issues and PR in this repo related strictly to the opaque library.

Report any protocol-specific issues in their respective repositories

Please first refer to the general StreamingFast contribution guide, if you wish to contribute to this code base.

This codebase uses unit tests extensively, please write and run tests.

License

Apache 2.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(opaqueKey string) ([]byte, error)

Decode de-obfuscates (decrypts) internal keys to be used as pagination cursors sent to frontend

func DecodeToString

func DecodeToString(opaqueKey string) (string, error)

DecodeToString de-obfuscates (decrypts) internal keys to be used as pagination cursors sent to frontend

func Encode

func Encode(internalKey []byte) string

Encode obfuscates (encrypts) internal keys to be used as pagination cursors sent to frontend

func EncodeString

func EncodeString(internalKey string) string

EncodeString obfuscates (encrypts) internal keys to be used as pagination cursors sent to frontend

func FromOpaque deprecated

func FromOpaque(opaqueKey string) (string, error)

FromOpaque de-obfuscates (decrypts) internal keys to be used as pagination cursors sent to frontend

Deprecated: Use DecodeToString instead.

func ToOpaque deprecated

func ToOpaque(internalKey string) (string, error)

ToOpaque obfuscates (encrypts) internal keys to be used as pagination cursors sent to frontend

Deprecated: Use EncodeString instead.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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