Initial commit

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-11-07 10:47:18 +08:00
co-authored by Claude Opus 4.7
commit 79ac89b458
708 changed files with 151634 additions and 0 deletions
+68
View File
@@ -0,0 +1,68 @@
package maths
import (
"math/big"
"strings"
uuid "github.com/satori/go.uuid"
)
const CODE62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
const CodeLenth = 62
/**
* 10进制 为 62进制 字符串。大数字类型
*
* param: *big.Int number 待转换的数字,非常大的
* return: string
*/
func From10To62Big(number *big.Int) string {
tmpNumber := big.NewInt(0)
var result []byte
for number.Cmp(big.NewInt(0)) != 0 {
var tmp []byte
tmpNumber.Rem(number, big.NewInt(CodeLenth))
tmp = append(tmp, CODE62[tmpNumber.Int64()])
result = append(tmp, result...)
number.Div(number, big.NewInt(CodeLenth))
}
return string(result)
}
/**
* 10进制 为 62进制 字符串。大数字类型
*
* param: int64 num 待转换的数字
* return: string
*/
func From10To62(number int64) string {
var result []byte
for number != 0 {
var tmp []byte
number1 := number % CodeLenth
tmp = append(tmp, CODE62[number1])
result = append(tmp, result...)
number = number / CodeLenth
}
return string(result)
}
func GenUUID() string {
u1 := uuid.Must(uuid.NewV4(), nil).String()
uuidStr := strings.Replace(u1, "-", "", -1)
number, _ := new(big.Int).SetString(uuidStr, 16)
return From10To62Big(number)
}
func Abs(n int64) int64 {
if n < 0 {
return -n
}
return n
}
func Gen32String() string {
u1 := uuid.Must(uuid.NewV4(), nil).String()
uuidStr := strings.Replace(u1, "-", "", -1)
return uuidStr
}