We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Which base62 implementations is this compatible with?
For reference, I believe this is what base62 encoding and decoding should look like:
Raw : "Hello, 世界" Base64: SGVsbG8sIOS4lueVjA (18 chars) Base62: 1wJfrzvdbuFbL65vcS (18 chars) Raw : "Hello World" Base64: SGVsbG8gV29ybGQ (15 chars) Base62: 73XpUgyMwkGr29M (15 chars) Raw : [ 0, 0, 0, 0, 255, 255, 255, 255 ] Base64: AAAAAP____8 (11 chars) Base62: 000004gfFC3 (11 chars) Raw : [ 255, 255, 255, 255, 0, 0, 0, 0 ] Base64: _____wAAAAA (11 chars) Base62: LygHZwPV2MC (11 chars)
I generated that using https://github.com/keybase/saltpack/encoding/basex, which seems to be correct and agree with other implementations, such as https://github.com/oconnor663/basex_gmp.
package main import ( "encoding/base64" "fmt" "github.com/keybase/saltpack/encoding/basex" ) func main() { for _, src := range [][]byte{ []byte("Hello, 世界"), []byte("Hello World"), {0, 0, 0, 0, 255, 255, 255, 255}, {255, 255, 255, 255, 0, 0, 0, 0}, } { // Uses the GMP character set "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" b62 := basex.Base62StdEncoding.EncodeToString(src) b64 := base64.RawURLEncoding.EncodeToString(src) fmt.Printf("Base64: %s (%d chars)\n", b64, len(b64)) fmt.Printf("Base62: %s (%d chars)\n", b62, len(b62)) fmt.Println("") } }
The text was updated successfully, but these errors were encountered:
Hi @coolaj86, this lib seems to produce the same results:
import io.seruco.encoding.base62.Base62; import java.nio.charset.StandardCharsets; class Scratch { public static void main(String[] args) { outputEncoded("Hello, 世界".getBytes(StandardCharsets.UTF_8)); outputEncoded("Hello World".getBytes(StandardCharsets.UTF_8)); outputEncoded(toByteArray(0, 0, 0, 0, 255, 255, 255, 255 )); outputEncoded(toByteArray(255, 255, 255, 255, 0, 0, 0, 0 )); } private static void outputEncoded(byte[] unencoded) { byte[] bytes = Base62.createInstance().encode(unencoded); System.out.println(new String(bytes, StandardCharsets.US_ASCII)); } private static byte[] toByteArray(int... values) { byte[] result = new byte[values.length]; for (int i = 0; i < values.length; i++) { result[i] = (byte) values[i]; } return result; } }
Running it produces
1wJfrzvdbuFbL65vcS 73XpUgyMwkGr29M 00004gfFC3 LygHZwPV2MC
Sorry, something went wrong.
No branches or pull requests
Which base62 implementations is this compatible with?
Reference Strings
For reference, I believe this is what base62 encoding and decoding should look like:
Reference Implementation
I generated that using https://github.com/keybase/saltpack/encoding/basex, which seems to be correct and agree with other implementations, such as https://github.com/oconnor663/basex_gmp.
The text was updated successfully, but these errors were encountered: