Skip to content

Commit

Permalink
feat: add EncryptJSON method
Browse files Browse the repository at this point in the history
  • Loading branch information
saitofun committed May 14, 2024
1 parent ced25a9 commit 2120efc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/ioconnect/jwk.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,17 @@ func (k *JWK) VerifyToken(token string) (string, error) {
return vc.CredentialSubject[0].ID, nil
}

func (k *JWK) EncryptJSON(v any, recipient string) ([]byte, error) {
if v == nil {
return nil, errors.New("expect non-empty input `v`")
}
plain, err := json.Marshal(v)
if err != nil {
return nil, err
}
return k.Encrypt(plain, recipient)
}

func (k *JWK) Encrypt(plain []byte, recipient string) ([]byte, error) {
data := (*C.char)(C.CBytes(plain))
defer C.free(unsafe.Pointer(data))
Expand Down

0 comments on commit 2120efc

Please sign in to comment.