Skip to content

Commit 9c969e2

Browse files
Juanita De La CuestaJuanita De La Cuesta
authored andcommitted
Func: Make internal functions private
1 parent 36bf4e1 commit 9c969e2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

signature/signature.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const sHeader = "MessageBird-Signature"
2222
type ValidityPeriod *float64
2323

2424
// StringToTime converts from Unicod Epoch enconded timestamps to time.Time Go objects
25-
func StringToTime(s string) (time.Time, error) {
25+
func stringToTime(s string) (time.Time, error) {
2626
sec, err := strconv.ParseInt(s, 10, 64)
2727
if err != nil {
2828
return time.Time{}, err
@@ -32,7 +32,7 @@ func StringToTime(s string) (time.Time, error) {
3232

3333
// HMACSHA256 generates HMACS enconded hashes using the provided Key and SHA256
3434
// encoding for the message
35-
func HMACSHA256(message, key []byte) ([]byte, error) {
35+
func hMACSHA256(message, key []byte) ([]byte, error) {
3636
mac := hmac.New(sha256.New, []byte(key))
3737
if _, err := mac.Write(message); err != nil {
3838
return nil, err
@@ -61,7 +61,7 @@ func NewValidator(signingKey string, period ValidityPeriod, log *log.Logger, mes
6161
// ValidTimestamp validates if the MessageBird-Request-Timestamp is a valid
6262
// date and if the request is older than the validator Period.
6363
func (v *Validator) ValidTimestamp(ts string) bool {
64-
t, err := StringToTime(ts)
64+
t, err := stringToTime(ts)
6565
if err != nil {
6666
return false
6767
}
@@ -84,7 +84,7 @@ func (v *Validator) CalculateSignature(ts, qp string, b []byte) ([]byte, error)
8484
var m bytes.Buffer
8585
bh := sha256.Sum256(b)
8686
fmt.Fprintf(&m, "%s\n%s\n%s", ts, qp, bh[:])
87-
s, err := HMACSHA256(m.Bytes(), []byte(v.SigningKey))
87+
s, err := hMACSHA256(m.Bytes(), []byte(v.SigningKey))
8888
if err != nil {
8989
return nil, err
9090
}

0 commit comments

Comments
 (0)