Bugfix: The hash was wrong

* The checksum must be uppercase
* The data string was wrong
This commit is contained in:
Thorsten Sommer 2015-07-14 16:33:50 +02:00
parent 858cfc81e4
commit 0bca5ebb7b

View File

@ -6,6 +6,7 @@ import (
"github.com/SommerEngineering/Ocean/Tools" "github.com/SommerEngineering/Ocean/Tools"
"net/url" "net/url"
"sort" "sort"
"strings"
) )
// Sign a message to secure it. // Sign a message to secure it.
@ -32,7 +33,7 @@ func signMessage(data map[string][]string) (result url.Values) {
// Now, loop over all the data: // Now, loop over all the data:
for _, key := range keys { for _, key := range keys {
// Get the value: // Get the value:
value := data[key] value := data[key][0]
// Hash each key and value: // Hash each key and value:
fmt.Fprintf(hash, "key=%s :: value=%s\n", key, value) fmt.Fprintf(hash, "key=%s :: value=%s\n", key, value)
@ -42,6 +43,6 @@ func signMessage(data map[string][]string) (result url.Values) {
result = url.Values(data) result = url.Values(data)
// Append the sign: // Append the sign:
result.Add(`checksum`, fmt.Sprintf("%x", hash.Sum(nil))) result.Add(`checksum`, strings.ToUpper(fmt.Sprintf("%x", hash.Sum(nil))))
return return
} }