Skip to content

Commit

Permalink
also output sha256 digest when generating certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
izolight committed Nov 24, 2019
1 parent ebe0199 commit 6f10f22
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package generator
import (
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"crypto/x509"
"encoding/json"
"encoding/pem"
Expand Down Expand Up @@ -35,6 +36,7 @@ specifically, section 10.2.3 ("Information Requirements").`
type Sum struct {
MD5 string `json:"md5"`
SHA1 string `json:"sha-1"`
SHA256 string `json:"sha-256"`
}

// Validator is a type of function that contains the logic for validating
Expand Down Expand Up @@ -97,8 +99,10 @@ func computeSum(in []byte) (sum Sum, err error) {

md5Sum := md5.Sum(data)
sha1Sum := sha1.Sum(data)
sha256Sum := sha256.Sum256(data)
sum.MD5 = fmt.Sprintf("%X", md5Sum[:])
sum.SHA1 = fmt.Sprintf("%X", sha1Sum[:])
sum.SHA256 = fmt.Sprintf("%X", sha256Sum[:])
return
}

Expand Down

0 comments on commit 6f10f22

Please sign in to comment.