github.com/blend/go-sdk@v1.20220411.3/crypto/hmac.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package crypto 9 10 import ( 11 "crypto/hmac" 12 "crypto/sha256" 13 "crypto/sha512" 14 ) 15 16 // HMAC512 sha512 hashes data with the given key. 17 func HMAC512(key, plainText []byte) []byte { 18 mac := hmac.New(sha512.New, key) 19 _, _ = mac.Write([]byte(plainText)) 20 return mac.Sum(nil) 21 } 22 23 // HMAC256 sha256 hashes data with the given key. 24 func HMAC256(key, plainText []byte) []byte { 25 mac := hmac.New(sha256.New, key) 26 _, _ = mac.Write([]byte(plainText)) 27 return mac.Sum(nil) 28 }