return
}
+func (t *Crypto) LoadPKIXPubKey(path string) (err error) {
+ if d,e := FileLoad(path);e != nil {
+ return e
+ } else {
+ err = t.GetPKIXPubKey(d)
+ }
+ return
+}
+
func (t *Crypto) GetPKCS1PriKey(priPEMData []byte) (err error) {
block, _ := pem.Decode(priPEMData)
if block == nil || block.Type != "RSA PRIVATE KEY" {
return
}
+func (t *Crypto) LoadPKCS1PriKey(path string) (err error) {
+ if d,e := FileLoad(path);e != nil {
+ return e
+ } else {
+ err = t.GetPKCS1PriKey(d)
+ }
+ return
+}
+
func (t *Crypto) GetEncrypt(sourceByte []byte) (tragetByte []byte, err error) {
if t.pubKey == nil {
err = errors.New(`public key not load`)
var k Crypto
if k.PubLoad() || k.PriLoad() {t.Error(`Keystatus not PublicKeyNoLoad`)}
{
- d,_ := FileLoad(`public.pem`)
- k.GetPKIXPubKey(d)
+ k.LoadPKIXPubKey(`public.pem`)
}
if !k.PubLoad() || k.PriLoad() {t.Error(`Keystatus not PrivateKeyNoLoad`)}
{
} else {
if s := string(des);s != `1we23` {t.Error(`not Match`,s)}
}
+
+ if des,e := k.GetDecrypt([]byte(`1we23`));e == nil {
+ t.Error(des,e)
+ }
}
\ No newline at end of file