// EncodeMd5 encodes a string to md5 hex value.
778612
func EncodeMd5(str string) string {
	m := md5.New()
	m.Write([]byte(str))
	return hex.EncodeToString(m.Sum(nil))
}
1228899
func (todo *Todo) Encode() (*bytes.Buffer, error) {
	b, err := json.Marshal(todo)
	if err != nil {
		return &bytes.Buffer{}, err
	}
	return bytes.NewBuffer(b), nil
}
339719
func Encode(code string) (barcode.BarcodeIntCS, error) {
	var checkSum int
	if len(code) == 7 || len(code) == 12 {
		code += string(calcCheckNum(code))
		checkSum = utils.RuneToInt(calcCheckNum(code))
	} else if len(code) == 8 || len(code) == 13 {
		check := code[0 : len(code)-1]
		check += string(calcCheckNum(check))
		if check != code {
			return nil, errors.New("checksum missmatch")
		}
		checkSum = utils.RuneToInt(rune(code[len(code)-1]))
	}

	if len(code) == 8 {
		result := encodeEAN8(code)
		if result != nil {
			return utils.New1DCodeIntCheckSum(barcode.TypeEAN8, code, result, checkSum), nil
		}
	} else if len(code) == 13 {
		result := encodeEAN13(code)
		if result != nil {
			return utils.New1DCodeIntCheckSum(barcode.TypeEAN13, code, result, checkSum), nil
		}
	}
	return nil, errors.New("invalid ean code data")
}
80449
func contentMD5(r *request.Request) {
	h := md5.New()

	if !aws.IsReaderSeekable(r.Body) {
		if r.Config.Logger != nil {
			r.Config.Logger.Log(fmt.Sprintf(
				"Unable to compute Content-MD5 for unseekable body, S3.%s",
				r.Operation.Name))
		}
		return
	}

	if _, err := copySeekableBody(h, r.Body); err != nil {
		r.Error = awserr.New("ContentMD5", "failed to compute body MD5", err)
		return
	}

	// encode the md5 checksum in base64 and set the request header.
	v := base64.StdEncoding.EncodeToString(h.Sum(nil))
	r.HTTPRequest.Header.Set(contentMD5Header, v)
}
1325628
func EncodePassword(pwd string) string {
	if len(pwd) == 0 {
		return ""
	}
	hash := Sha1Hash([]byte(pwd))
	return hex.EncodeToString(hash)
}
416027
func MD5String(f string) string {
	h := md5.New()
	h.Write([]byte(f))
	return hex.EncodeToString(h.Sum([]byte{}))
}
961046
func Encode(content string, includeChecksum bool, fullASCIIMode bool) (barcode.BarcodeIntCS, error) {
	if fullASCIIMode {
		var err error
		content, err = prepare(content)
		if err != nil {
			return nil, err
		}
	} else if strings.ContainsRune(content, '*') {
		return nil, errors.New("invalid data! try full ascii mode")
	}

	data := "*" + content
	if includeChecksum {
		data += getChecksum(content)
	}
	data += "*"

	result := new(utils.BitList)

	for i, r := range data {
		if i != 0 {
			result.AddBit(false)
		}

		info, ok := encodeTable[r]
		if !ok {
			return nil, errors.New("invalid data! try full ascii mode")
		}
		result.AddBit(info.data...)
	}

	checkSum, err := strconv.ParseInt(getChecksum(content), 10, 64)
	if err != nil {
		checkSum = 0
	}
	return utils.New1DCodeIntCheckSum(barcode.TypeCode39, content, result, int(checkSum)), nil
}
512321
func (c *UpdateAddHTLC) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		c.ChanID,
		c.ID,
		c.Amount,
		c.PaymentHash[:],
		c.Expiry,
		c.OnionBlob[:],
	)
}
388375
func (pp *Pubrec) Encode(dst []byte) (int, error) {
	return identifiedEncode(dst, pp.ID, PUBREC)
}
642555
func EncodePassword(password string, salt string) string {
	newPasswd := PBKDF2([]byte(password), []byte(salt), 10000, 50, sha256.New)
	return hex.EncodeToString(newPasswd)
}
982404
func Md5Sum(reader io.Reader) (string, error) {
	var returnMD5String string
	hash := md5.New()
	if _, err := io.Copy(hash, reader); err != nil {
		return returnMD5String, err
	}
	hashInBytes := hash.Sum(nil)[:16]
	returnMD5String = hex.EncodeToString(hashInBytes)
	return returnMD5String, nil
}
802922
func (enc *Encoder) Encode(id uint64) string {

	if id == 0 {
		return string(enc.encode[:1])
	}

	bin := make([]byte, 0, binary.MaxVarintLen64)
	for id > 0 {
		bin = append(bin, enc.encode[id%58])
		id /= 58
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return string(bin)
}
1319350
func MD5Bytes(str string) []byte {
	m := md5.New()
	m.Write([]byte(str))
	return m.Sum(nil)
}
247262
func Encode(providerName []byte, params string, salt []byte, key []byte) (res []byte) {
	salt64 := encodeBase64(salt)
	key64 := encodeBase64(key)
	// final res len = len(providerName) + len(params) + len(salt) + len(key) + 4, because we need 4 dividers
	res = append(res, Divider)
	res = append(res, providerName...)
	res = append(res, Divider)
	res = append(res, params...)
	res = append(res, Divider)
	res = append(res, salt64...)
	res = append(res, Divider)
	res = append(res, key64...)
	return res
}
518900
func (d *Context) HexEncode(index int) string {
	if s := C.duk_hex_encode(d.duk_context, C.duk_idx_t(index)); s != nil {
		return C.GoString(s)
	}
	return ""
}
969453
func (e StringEncoder) Encode(data interface{}, out *goetty.ByteBuf) error {
	msg, _ := data.(string)
	bytes := []byte(msg)
	out.WriteInt(len(bytes))
	out.Write(bytes)
	return nil
}
928499
func (enc *Encoder) Encode(m *Message) (err error) {

	_, err = enc.Write(m.Bytes())

	return
}