我试图让Java验证签名的SHA-1哈希,但是它一直返回false。我在Go中有以下代码,该代码生成RSA密钥对并签名并返回击中/
sign端点的任何消息,以及十六进制编码的哈希,公钥模数和指数:
package main
import (
"crypto"
"crypto/rand"
"crypto/rsa"
"encoding/hex"
"encoding/json"
"fmt"
"io"
"net/http"
"strconv"
)
var PrivKey *rsa.PrivateKey
type Message struct {
Message string `json:"message"`
}
func (msg *Message) Decode(r io.Reader) error {
return json.NewDecoder(r).Decode(&msg)
}
type Signature struct {
Hash string `json:"hash"`
Signature string `json:"signature"`
N string `json:"N"`
E string `json:"E"`