MCPcopy
hub / github.com/projectdiscovery/katana / Hash

Method Hash

pkg/engine/headless/types/types.go:208–239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

206}
207
208func (f *HTMLForm) Hash() string {
209 hasher := md5.New()
210
211 var parts []string
212 parts = append(parts, f.TagName)
213
214 if f.ID != "" {
215 parts = append(parts, "id:"+f.ID)
216 }
217 if f.Classes != "" {
218 parts = append(parts, "class:"+f.Classes)
219 }
220
221 // Add stable attributes
222 stableAttrs := getStableAttributes(f.Attributes)
223 for _, k := range stableAttrs {
224 parts = append(parts, fmt.Sprintf("%s:%s", k, f.Attributes[k]))
225 }
226 parts = append(parts, fmt.Sprintf("action:%s", f.Action), fmt.Sprintf("method:%s", f.Method))
227
228 // Include hashes of form elements
229 for _, element := range f.Elements {
230 parts = append(parts, element.Hash())
231 }
232
233 hashInput := strings.Join(parts, "|")
234 if IsDiagnosticEnabled {
235 fmt.Fprintf(os.Stderr, "[diagnostic] Form hash input: %s\n", hashInput)
236 }
237 hasher.Write([]byte(hashInput))
238 return hex.EncodeToString(hasher.Sum(nil))
239}
240
241// getStableAttributes returns a sorted slice of attribute keys that are considered stable.
242func getStableAttributes(attrs map[string]string) []string {

Callers

nothing calls this directly

Calls 3

getStableAttributesFunction · 0.85
WriteMethod · 0.65
HashMethod · 0.45

Tested by

no test coverage detected