- Go 100%
|
All checks were successful
Backend Build and Test / backend-tasks (push) Successful in 42s
|
||
|---|---|---|
| .forgejo/workflows | ||
| .gitignore | ||
| abcex.go | ||
| abcex_test.go | ||
| CHANGELOG | ||
| go.mod | ||
| README.md | ||
abcex
Computing system based on the number 62, 36 or 16
Usage
Encode(int, int) -> string - convert number into string based on given base.
Decode(string, int) -> int - convert from encoded string into number based on given base.
Convert(string, int, int) -> string - convert encoded string from one base to another.
Valid(string, int) -> bool - check if string is valid for given base.
Plus(string, string, int) -> string - add two encoded strings for given base.
Minus(string, string, int) -> string - subtract two encoded strings for given base.
Sum([]string, int) -> string - sum multiple encoded strings for given base.
Encrypt(string, int) -> (string, error) - convert all text elements into integers and replace in text :P
Decrypt(string, int) -> (string, error) - convert all integers into text elements and replace in text ;)
Diacritical marks support
For Lithuanian, Latvian, Samogitian alphabets, we use a mapping during Encrypt/Decrypt:
ā,ē,ī,ō,ūare mapped using|marker (e.g.,ā->a|,Ā->A|)ė,ȧare mapped using*marker (e.g.,ė->e*,Ė->E*)š,č,žare mapped using^marker (e.g.,š->s^,Š->S^)ą,ę,į,ų,ģ,ķ,ļ,ŗare mapped using+marker (e.g.,ą->a+,Ą->A+)
Special combinations like ė̄ are supported as e*| (and Ė̄ as E*|).
|
During encryption, these markers act as delimiters and are preserved in the encrypted text. |, ^, +, and * all appear in the output to separate encoded values.
History
Version 1 - based on 32: number and case insensitive letters
Version 2 - failed release
Version 3 - based on 62: number and case sensitive letters
Version 4 - support both versions, based on 62 and 32
Comparisons
DEC | abcex.BASE36 | shorter
-----------------------------------------
12 | c | 2:1
100 | 2s | 3:2
2000 | 1jk | 4:3
1000000 | lfls | 7:4
1000000000 | gjdgxs | 10:6
1000000000000 | cre66i9s | 13:8
DEC | abcex.BASE62 | shorter
-----------------------------------------
12 | C | 2:1
100 | 1c | 3:2
2000 | WG | 4:2
1000000 | 4C92 | 7:4
1000000000 | 15ftgG | 10:6
1000000000000 | HbXm5a4 | 13:7