Documentation
¶
Index ¶
- Constants
- Variables
- func CommonJSONHash(j []byte) ([]byte, error)
- func Filtered(o interface{}, allowed string) (interface{}, error)
- func ObjectHash(o interface{}) ([]byte, error)
- func ObjectHashWithRedaction(o interface{}, redPref string) ([]byte, error)
- func ObjectHashWithStdRedaction(o interface{}) ([]byte, error)
- func RedactWithRedaction(i interface{}, redPref string) (string, error)
- func RedactWithStdRedaction(i interface{}) (string, error)
- func Redactable(o interface{}) (interface{}, error)
- func RedactableIt(p interface{}) (interface{}, error)
- func Unredactable(o interface{}, redPref string) (interface{}, error)
- func UnredactableWithStdPrefix(o interface{}) (interface{}, error)
- type Filterer
- type Set
Examples ¶
Constants ¶
View Source
const (
REDACTED_PREFIX = "***REDACTED*** Hash: "
)
Variables ¶
Functions ¶
func CommonJSONHash ¶
Example (Common) ¶
commonJSON(`["foo", "bar"]`)
Output: 32ae896c413cfdc79eec68be9139c86ded8b279238467c216cf2bec4d5f1e4a2
Example (FloatAndInt) ¶
commonJSON(`["foo", {"bar":["baz", null, 1.0, 1.5, 0.0001, 1000.0, 2.0, -23.1234, 2.0]}]`)
// Integers and floats are the same in common JSON
commonJSON(`["foo", {"bar":["baz", null, 1, 1.5, 0.0001, 1000, 2, -23.1234, 2]}]`)
Output: 783a423b094307bcb28d005bc2f026ff44204442ef3513585e7e73b66e3c2213 783a423b094307bcb28d005bc2f026ff44204442ef3513585e7e73b66e3c2213
Example (KeyChange) ¶
commonJSON(`["foo", {"b4r":["baz", null, 1, 1.5, 0.0001, 1000, 2, -23.1234, 2]}]`)
Output: 7e01f8b45da35386e4f9531ff1678147a215b8d2b1d047e690fd9ade6151e431
Example (KeyOrderIndependence) ¶
commonJSON(`{"k1":"v1","k2":"v2","k3":"v3"}`)
commonJSON(`{"k2":"v2","k1":"v1","k3":"v3"}`)
Output: ddd65f1f7568269a30df7cafc26044537dc2f02a1a0d830da61762fc3e687057 ddd65f1f7568269a30df7cafc26044537dc2f02a1a0d830da61762fc3e687057
func Filtered ¶
Filter a previously redacted object.
Format of allowed is: expr(,expr)* Format of expr is: ident(/ident)* Format if ident is: either * or not a comma or /
func ObjectHash ¶
Example (ComplexSet) ¶
o := Set{`foo`, 23.6, Set{Set{}}, Set{Set{1}}}
objectHash(o)
Output: 3773b0a5283f91243a304d2bb0adb653564573bc5301aa8bb63156266ea5d398
Example (ComplexSetRepeated) ¶
o := Set{`foo`, 23.6, Set{Set{}}, Set{Set{1}}, Set{Set{}}}
objectHash(o)
Output: 3773b0a5283f91243a304d2bb0adb653564573bc5301aa8bb63156266ea5d398
Example (Json) ¶
// Same as equivalent JSON object
o := []any{`foo`, `bar`}
objectHash(o)
Output: 32ae896c413cfdc79eec68be9139c86ded8b279238467c216cf2bec4d5f1e4a2
Example (Json2) ¶
// Same as equivalent _Python_ JSON object
o := []any{`foo`, map[string]any{`bar`: []any{`baz`, nil, 1, 1.5, 0.0001, 1000, 2, -23.1234, 2}}}
objectHash(o)
// Same as equivalent Common JSON object
o = []any{`foo`, map[string]any{`bar`: []any{`baz`, nil, 1.0, 1.5, 0.0001, 1000.0, 2.0, -23.1234, 2.0}}}
objectHash(o)
Output: 726e7ae9e3fadf8a2228bf33e505a63df8db1638fa4f21429673d387dbd1c52a 783a423b094307bcb28d005bc2f026ff44204442ef3513585e7e73b66e3c2213
Example (Set) ¶
o := map[string]any{`thing1`: map[string]any{`thing2`: Set{1, 2, `s`}}, `thing3`: 1234.567}
objectHash(o)
Output: 618cf0582d2e716a70e99c2f3079d74892fec335e3982eb926835967cb0c246c
func ObjectHashWithRedaction ¶
func RedactWithRedaction ¶
func RedactWithStdRedaction ¶
func Redactable ¶
func Redactable(o interface{}) (interface{}, error)
func RedactableIt ¶
func RedactableIt(p interface{}) (interface{}, error)
func Unredactable ¶
func UnredactableWithStdPrefix ¶
func UnredactableWithStdPrefix(o interface{}) (interface{}, error)
* Unredact stuff
Types ¶
type Filterer ¶
func CreateFilterer ¶
Click to show internal directories.
Click to hide internal directories.