return 11 chars base 62 representation of a big int base chars are 0-9 a-z A-Z
(num *big.Int)
| 63 | // return 11 chars base 62 representation of a big int |
| 64 | // base chars are 0-9 a-z A-Z |
| 65 | func BigToBase62(num *big.Int) string { |
| 66 | digits := []byte{} |
| 67 | n := big.NewInt(0) |
| 68 | n.Add(n, num) |
| 69 | zero := big.NewInt(0) |
| 70 | base := big.NewInt(62) |
| 71 | for { |
| 72 | mod := big.NewInt(0) |
| 73 | n, mod = n.DivMod(n, base, mod) |
| 74 | mBytes := mod.Bytes() |
| 75 | if len(mBytes) == 0 { |
| 76 | digits = append(digits, 0) |
| 77 | } else { |
| 78 | digits = append(digits, mod.Bytes()[0]) |
| 79 | } |
| 80 | if n.Cmp(zero) == 0 { |
| 81 | break |
| 82 | } |
| 83 | } |
| 84 | l := len(digits) |
| 85 | for i := 0; i < 11-l; i++ { |
| 86 | digits = append(digits, 0) |
| 87 | } |
| 88 | return base62DigitsToString(digits) |
| 89 | } |
| 90 | |
| 91 | func (h SPHash) Str() string { return string(h[:]) } |
| 92 | func (h SPHash) Bytes() []byte { return h[:] } |
nothing calls this directly
no test coverage detected