mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 08:32:40 +08:00
加密包装
This commit is contained in:
35
crypto/ecdsa_test.go
Normal file
35
crypto/ecdsa_test.go
Normal file
@ -0,0 +1,35 @@
|
||||
package crypto_test
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"crypto/elliptic"
|
||||
"crypto/rand"
|
||||
"crypto/x509"
|
||||
"encoding/asn1"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/charlienet/go-mixed/crypto"
|
||||
)
|
||||
|
||||
func TestEsda(t *testing.T) {
|
||||
|
||||
prv, err := ecdsa.GenerateKey(elliptic.P521(), rand.Reader)
|
||||
t.Log(err)
|
||||
|
||||
ecd, err := x509.MarshalECPrivateKey(prv)
|
||||
t.Log(err)
|
||||
|
||||
secp256r1, _ := asn1.Marshal(asn1.ObjectIdentifier{1, 2, 840, 10045, 3, 1, 7})
|
||||
fmt.Println(string(pem.EncodeToMemory(&pem.Block{Type: "EC PARAMETERS", Bytes: secp256r1})))
|
||||
b := pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: ecd})
|
||||
fmt.Println(string(b))
|
||||
}
|
||||
|
||||
func TestSign(t *testing.T) {
|
||||
ecdsa, err := crypto.NewEcdsa(crypto.SHA1)
|
||||
t.Log(err)
|
||||
|
||||
_ = ecdsa
|
||||
}
|
Reference in New Issue
Block a user