opaque

package module
v0.0.0-...-bc02ec9 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

README

dfuse Opaque library

reference License

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

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 dfuse contribution guide, if you wish to contribute to this code base.

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