@@ -22,7 +22,7 @@ const sHeader = "MessageBird-Signature"
22
22
type ValidityPeriod * float64
23
23
24
24
// 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 ) {
26
26
sec , err := strconv .ParseInt (s , 10 , 64 )
27
27
if err != nil {
28
28
return time.Time {}, err
@@ -32,7 +32,7 @@ func StringToTime(s string) (time.Time, error) {
32
32
33
33
// HMACSHA256 generates HMACS enconded hashes using the provided Key and SHA256
34
34
// encoding for the message
35
- func HMACSHA256 (message , key []byte ) ([]byte , error ) {
35
+ func hMACSHA256 (message , key []byte ) ([]byte , error ) {
36
36
mac := hmac .New (sha256 .New , []byte (key ))
37
37
if _ , err := mac .Write (message ); err != nil {
38
38
return nil , err
@@ -61,7 +61,7 @@ func NewValidator(signingKey string, period ValidityPeriod, log *log.Logger, mes
61
61
// ValidTimestamp validates if the MessageBird-Request-Timestamp is a valid
62
62
// date and if the request is older than the validator Period.
63
63
func (v * Validator ) ValidTimestamp (ts string ) bool {
64
- t , err := StringToTime (ts )
64
+ t , err := stringToTime (ts )
65
65
if err != nil {
66
66
return false
67
67
}
@@ -84,7 +84,7 @@ func (v *Validator) CalculateSignature(ts, qp string, b []byte) ([]byte, error)
84
84
var m bytes.Buffer
85
85
bh := sha256 .Sum256 (b )
86
86
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 ))
88
88
if err != nil {
89
89
return nil , err
90
90
}
0 commit comments