2020-11-21 11:53:07 +00:00
|
|
|
package output
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/sha256"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
type File struct {
|
2023-09-02 21:49:02 +00:00
|
|
|
name string
|
2020-11-21 11:53:07 +00:00
|
|
|
content []byte
|
2023-09-02 21:49:02 +00:00
|
|
|
origin string
|
|
|
|
hash string
|
2020-11-21 11:53:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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,
|
|
|
|
}
|
2023-09-02 21:49:02 +00:00
|
|
|
}
|