package mycrypto import ( "crypto/md5" "fmt" ) type Md5Crypto struct{} func NewMd5Crypto() (md5Crypto *Md5Crypto) { return &Md5Crypto{} } func (rsaCrypto *Md5Crypto) Encrypt(msg []byte) (encryptedBytes []byte, err error) { hash := md5.Sum(msg) encryptedString := fmt.Sprintf("%x", hash) encryptedBytes = []byte(encryptedString) return } func (rsaCrypto *Md5Crypto) EncryptToString(msg []byte) (encryptedString string, err error) { hash := md5.Sum(msg) encryptedString = fmt.Sprintf("%x", hash) return }