From f664d725f69d2dfb5eef662d703419e4cafd1257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=A1=D0=B5?= =?UTF-8?q?=D0=B4=D1=8B=D1=85?= Date: Fri, 8 Jan 2016 05:12:05 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6?= =?UTF-8?q?=D0=BA=D0=B0=20HS256,=20HS384,=20HS512?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- signer.go | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/signer.go b/signer.go index fff739d..0b3c51b 100644 --- a/signer.go +++ b/signer.go @@ -4,6 +4,7 @@ import ( "bytes" "crypto/hmac" "crypto/sha256" + "crypto/sha512" "encoding/base64" "encoding/json" "errors" @@ -26,23 +27,23 @@ func NewSignerHS256(key []byte) *Signer { } } -// // NewSignerHS384 возвращает инициализированный подписчик токена. -// func NewSignerHS384(key []byte) *Signer { -// return &Signer{ -// hash: hmac.New(sha512.New384, key), -// name: "HS384", -// header: getHeader("HS384"), -// } -// } +// NewSignerHS384 возвращает инициализированный подписчик токена. +func NewSignerHS384(key []byte) *Signer { + return &Signer{ + hash: hmac.New(sha512.New384, key), + name: "HS384", + header: getHeader("HS384"), + } +} -// // NewSignerHS512 возвращает инициализированный подписчик токена. -// func NewSignerHS512(key []byte) *Signer { -// return &Signer{ -// hash: hmac.New(sha512.New, key), -// name: "HS512", -// header: getHeader("HS512"), -// } -// } +// NewSignerHS512 возвращает инициализированный подписчик токена. +func NewSignerHS512(key []byte) *Signer { + return &Signer{ + hash: hmac.New(sha512.New, key), + name: "HS512", + header: getHeader("HS512"), + } +} // Sign возвращает подписанный токен. func (s Signer) Sign(token []byte) []byte {