MCPcopy Create free account
hub / github.com/activecm/rita / NewFixedStringHash

Function NewFixedStringHash

util/util.go:87–104  ·  view source on GitHub ↗

NewFixedStringHash creates a FixedString from a hash of all the passed in strings

(args ...string)

Source from the content-addressed store, hash-verified

85
86// NewFixedStringHash creates a FixedString from a hash of all the passed in strings
87func NewFixedStringHash(args ...string) (FixedString, error) {
88 if len(args) == 0 {
89 return FixedString{}, errors.New("no arguments provided")
90 }
91
92 joined := strings.Join(args, "")
93 if joined == "" {
94 return FixedString{}, errors.New("joined string is empty")
95 }
96
97 // #nosec
98 hash := md5.Sum([]byte(strings.Join(args, "")))
99
100 fs := FixedString{
101 Data: hash,
102 }
103 return fs, nil
104}
105
106// NewFixedStringFromString creates a FixedString from a passed in hex string
107func NewFixedStringFromHex(h string) (FixedString, error) {

Callers 15

TestBeaconsMethod · 0.92
TestProxyBeaconsFunction · 0.92
TestTLSProtoTableMethod · 0.92
TestHTTPProtoTableMethod · 0.92
formatHTTPRecordFunction · 0.92
writeLinkedHTTPMethod · 0.92
TestTruncatedTSVFunction · 0.92
TestTruncatedHeaderFunction · 0.92
TestTruncatedJSONFunction · 0.92
TestHasUnknownFieldTSVFunction · 0.92
TestPlainTextFileFunction · 0.92

Calls

no outgoing calls

Tested by 14

TestBeaconsMethod · 0.74
TestProxyBeaconsFunction · 0.74
TestTLSProtoTableMethod · 0.74
TestHTTPProtoTableMethod · 0.74
TestTruncatedTSVFunction · 0.74
TestTruncatedHeaderFunction · 0.74
TestTruncatedJSONFunction · 0.74
TestHasUnknownFieldTSVFunction · 0.74
TestPlainTextFileFunction · 0.74
generateSSLFunction · 0.74
verifyMetaDBCountsByIDFunction · 0.74