pancap/output/file.go

24 lines
415 B
Go
Raw Normal View History

2020-11-21 11:53:07 +00:00
package output
import (
"crypto/sha256"
"fmt"
)
type File struct {
name string
content []byte
origin string
hash string
}
// Creates a new file object and calculates the hash of the given content
func NewFile(name string, content []byte, origin string) File {
hash := fmt.Sprintf("%x", sha256.Sum256(content))[:6]
return File{
name: name,
content: content,
origin: origin,
hash: hash,
}
}