You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.
Currently, this package only has support for inputs of base/radix 36, due to math/bigMaxBase const being 36, as of June 29, 2017.
So, this package should have base62 support. This may involve the math/big package itself being updated, or a modified version of it must be used. See below.
In fact, because the math/big actually treats upper case and lower case alpha characters as the same, this actually causes a bug in this package. For example:
Supporting base 62 properly in math/big directly is very easy. Here's a diff on math/big/natconv.go that shows it. Ideally, this change will be accepted by Golang maintainers.
<// This file was has minor configurations compared to<// the standard library's math/big package in order<// to support base 62 conversions rather than base 36<21c17<constdigits="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"--->constdigits="0123456789abcdefghijklmnopqrstuvwxyz"27c23<constMaxBase=len(digits)
--->constMaxBase='z'-'a'+10+1179c175<d1=Word(ch-'A'+10+26)
--->d1=Word(ch-'A'+10)
181c177<d1=Word(MaxBase+1)
--->d1=MaxBase+1
While maintaining a customized version of math/big as a subpackage of fpe is not difficult, it's arguably not the best path forward.
The text was updated successfully, but these errors were encountered:
The Go team has added base62 support to the math/big library via golang/go@51cfe68
It should be available in Go 1.10.
As such, if you want base62 support with this library, please wait until Go 1.10 is released 😄
tl;dr on how to use base62 support is to set your radix to something between 36 and 62, with the understanding that the alphabet it follows is now 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
Description of Enhancement
Currently, this package only has support for inputs of base/radix 36, due to
math/big
MaxBase
const being 36, as of June 29, 2017.So, this package should have base62 support. This may involve the
math/big
package itself being updated, or a modified version of it must be used. See below.In fact, because the
math/big
actually treats upper case and lower case alpha characters as the same, this actually causes a bug in this package. For example:Encrypt Input:
abc123def
Encrypt Output:
flknlk32n
Encrypt Input:
ABC123DEF
Encrypt Output:
flknlk32n
(same as before)Decrypt input:
flknlk32n
Decrypt output:
abc123def
This is a collision of sorts.
Notes
Supporting base 62 properly in
math/big
directly is very easy. Here's a diff onmath/big/natconv.go
that shows it. Ideally, this change will be accepted by Golang maintainers.While maintaining a customized version of
math/big
as a subpackage offpe
is not difficult, it's arguably not the best path forward.The text was updated successfully, but these errors were encountered: