type HashRepo interface {
// checksum string once
Sum(s string) string
// checksum bytes once
SumBytes(bs []byte) string
// checksum string more times
SumTimes(s string, times uint) string
// checksum bytes more times
SumBytesTimes(bs []byte, times uint) string
}
md5
s := hash.NewHashRepo(crypto.MD5).Sum("test")
fmt.Println(s)
SHA1
s := hash.NewHashRepo(crypto.SHA1).Sum("test")
fmt.Println(s)
support hash
Calculate interests
func main() {
daily, _ := interests.GetInterestRepo(interests.CalcTypeDaily)
set := &interests.InterestSets{
RateType: interests.RateTypeDay,
InterestRate: 0.1 / 100,
PayTimes: 30,
Amount: 1000000,
StartDate: "2015-08-31",
}
payback, err := daily.CalcPayback(set)
fmt.Println(err, *payback)
}
func main() {
average, _ := interests.GetInterestRepo(interests.CalcTypeAverageCapital)
set := &interests.InterestSets{
RateType: interests.RateTypeDay,
InterestRate: 0.1 / 100,
PayTimes: 30,
Amount: 1000000,
StartDate: "2015-08-31",
}
payback, err := average.CalcPayback(set)
fmt.Println(err, *payback)
}
func main() {
plus, _ := interests.GetInterestRepo(interests.CalcTypeAverageCapitalPlus)
set := &interests.InterestSets{
RateType: interests.RateTypeDay,
InterestRate: 0.1 / 100,
PayTimes: 30,
Amount: 1000000,
StartDate: "2015-08-31",
}
payback, err := plus.CalcPayback(set)
fmt.Println(err, *payback)
}