storj/satellite/console/consoleauth/hmac.go
Yehor Butko e38cf8f50d
Renaming and moving pkg/satellite to satellite/console (#1054)
* [WIP] V3-853 Merge the satellite DB into the master database

* Removing consoleDB from satelliteDB

* Fixing tests for satellite/console

* fixing linter

* sorting imports in satellite/console

* fixing console config

* fixing linter
2019-01-15 15:03:24 +02:00

29 lines
481 B
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package consoleauth
import (
"crypto/hmac"
"crypto/sha256"
)
//TODO: change to JWT or Macaroon based auth
// Hmac is hmac256 based Signer
type Hmac struct {
Secret []byte
}
// Sign implements satellite signer
func (a *Hmac) Sign(data []byte) ([]byte, error) {
mac := hmac.New(sha256.New, a.Secret)
_, err := mac.Write(data)
if err != nil {
return nil, err
}
return mac.Sum(nil), nil
}