package signers import ( "crypto/md5" "fmt" "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/auth/credentials" ) type StsTokenSigner struct { credential *credentials.StdTokenCredential } func (signer *StsTokenSigner) GetAccessKeyId() (string, error) { return signer.credential.AccessKeyId, nil } func (signer *StsTokenSigner) GetAccessKeyFrom() (string, error) { return signer.credential.AccessKeyFrom, nil } func (*StsTokenSigner) GetName() string { return "MD5" } func (signer *StsTokenSigner) Sign(stringToSign, secretSuffix string) string { secret := signer.credential.AccessKeySecret + secretSuffix return Md5(stringToSign, secret) } func NewStsTokenSigner(credential *credentials.StdTokenCredential) *StsTokenSigner { return &StsTokenSigner{ credential: credential, } } func Md5(source, secret string) string { data := []byte(fmt.Sprintf("%s##%s", secret, source)) has := md5.Sum(data) md5str := fmt.Sprintf("%x", has) return md5str }