base64
1.rsa类型签名

1
2
3
4
5
6
7
8
9
10
import (
    "crypto/rsa"
    "crypto/rand"
)
signature, err := rsa.SignPKCS1v15(rand.Reader, privateKey.(*rsa.PrivateKey), crypto.SHA1, hash[:])
if err != nil {
    fmt.Printf("Error from signing: %s\n", err)
    return "", err
}
encoded := base64.StdEncoding.EncodeToString(signature)

2.rsa类型验签

1
2
3
4
5
import (
    "crypto/rsa"
)
 
rsa.VerifyPKCS1v15(pub *PublicKey, hash crypto.Hash, hashed []byte, sig []byte) error