package tools

import (
	"crypto/md5"
	"encoding/hex"
)

type Api struct {
	Tools  string        `json:"tools"`
	Values []interface{} `json:"values"`
}

func (p *Api) Run() interface{} {
	switch p.Tools {
	case "MD5":
		return p.Md5(p.Values[0].(string))
	}
	return nil
}

func (p *Api) Md5(data string) string {
	m := md5.New()
	m.Write([]byte(data))
	return hex.EncodeToString(m.Sum(nil))
}