Swift Base62 library.
Simply import the library and you're good to go.
import Base62
encode(integer: 123) // "1z"
decode(string: "funky") // 619367412
If you prefer, you can use Base62.encode
instead of just encode
.
It’s worth noting that you can’t decode an string with a value greater than Int.max
.
Thanks to the base62 gem for a reference implementation.