Skip to content

Commit

Permalink
golang-module/dongle->dromara/dongle
Browse files Browse the repository at this point in the history
  • Loading branch information
gouguoyin committed Nov 11, 2024
1 parent 3293d42 commit de7c99b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
14 changes: 11 additions & 3 deletions base62/base62.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@ import (

// An Encoding is a radix 62 encoding/decoding scheme, defined by a 62-character alphabet.
type Encoding struct {
table string
encode [62]byte
decodeMap [256]byte
}
type Config struct {
Table string
}

const encodeStd = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
var StdTable = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

// newEncoding returns a new padded Encoding defined by the given alphabet,
// which must be a 62-byte string that does not contain the padding character
// or CR / LF ('\r', '\n').
func newEncoding(encoder string) *Encoding {
func newEncoding(table string) *Encoding {
encoder := StdTable
if len(table) > 0 {
encoder = table
}
e := new(Encoding)
copy(e.encode[:], encoder)

Expand All @@ -31,7 +39,7 @@ func newEncoding(encoder string) *Encoding {
}

// StdEncoding is the standard base62 encoding.
var StdEncoding = newEncoding(encodeStd)
var StdEncoding = newEncoding(StdTable)

// Encode encodes src using the encoding enc.
func (enc *Encoding) Encode(src []byte) []byte {
Expand Down
10 changes: 5 additions & 5 deletions baseX.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"encoding/base64"
"encoding/hex"

"github.com/golang-module/dongle/base100"
"github.com/golang-module/dongle/base45"
"github.com/golang-module/dongle/base58"
"github.com/golang-module/dongle/base62"
"github.com/golang-module/dongle/base91"
"github.com/dromara/dongle/base100"
"github.com/dromara/dongle/base45"
"github.com/dromara/dongle/base58"
"github.com/dromara/dongle/base62"
"github.com/dromara/dongle/base91"
)

// ByHex encodes by hex.
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module github.com/golang-module/dongle
module github.com/dromara/dongle

go 1.14
go 1.16

require (
github.com/emmansun/gmsm v0.15.5
github.com/golang-module/dongle v0.2.8
github.com/stretchr/testify v1.7.0
golang.org/x/crypto v0.4.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emmansun/gmsm v0.15.5 h1:iLvUezUwA9WZHQFhK/UUhKhqviDczb28Qx+gynbvTKY=
github.com/emmansun/gmsm v0.15.5/go.mod h1:2m4jygryohSWkaSduFErgCwQKab5BNjURoFrn2DNwyU=
github.com/golang-module/dongle v0.2.8 h1:AcoquGAfoLjSlw1w9pglBziw5HvNbtd1B4XVjK10Hh0=
github.com/golang-module/dongle v0.2.8/go.mod h1:UhZVJiu/i4Sdsji5C5MuSF7lEH4cU1HsVVNdTHVdaq4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down

0 comments on commit de7c99b

Please sign in to comment.