hmac-generator: new program, to be able to test with curl
42sh$ echo toto | curl -d @- -H "X-ADLIN-Authentication: $(hmac-generator secret)" https://adlin.nemunai.re/api/secret
This commit is contained in:
parent
fa45457bb7
commit
b51b1e010a
1
hmac-generator/.gitignore
vendored
Normal file
1
hmac-generator/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
hmac-generator
|
19
hmac-generator/main.go
Normal file
19
hmac-generator/main.go
Normal file
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/sha512"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
sharedSecret := "adelina"
|
||||
if len(os.Args) > 1 {
|
||||
sharedSecret = os.Args[1]
|
||||
}
|
||||
|
||||
fmt.Println(base64.StdEncoding.EncodeToString(hmac.New(sha512.New, []byte(sharedSecret)).Sum([]byte(fmt.Sprintf("%d", time.Now().Unix()/10)))))
|
||||
}
|
Reference in New Issue
Block a user