package login import ( "context" "encoding/hex" "chainweaver.org.cn/chainweaver/did/did-mgr-common-service/internal/svc" "chainweaver.org.cn/chainweaver/did/did-mgr-common-service/internal/types" "chainweaver.org.cn/chainweaver/servicecommon/encrypt" "github.com/zeromicro/go-zero/core/logx" ) type EncryptLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext body []byte } func NewEncryptLogic(ctx context.Context, svcCtx *svc.ServiceContext, body []byte) *EncryptLogic { return &EncryptLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, body: body, } } func (l *EncryptLogic) Encrypt() (resp *types.CommonResp, err error) { edata, err := encrypt.Encrypt(l.body) if err != nil { l.Logger.Errorf("encrypt failed, err=%s", err.Error()) return nil, err } response := hex.EncodeToString(edata) return &types.CommonResp{ Code: types.SucceedCode, Msg: types.SucceedMsg, Data: response, }, nil }