Encode/decode a long to a string using a fixed set of letters in Java
Posted
by Hans Klock
on Stack Overflow
See other posts from Stack Overflow
or by Hans Klock
Published on 2010-05-30T11:53:42Z
Indexed on
2010/05/30
12:12 UTC
Read the original article
Hit count: 284
Given an arbitrary set of letters
String range = "0123456789abcdefghijklmnopABCD#";
I am looking for 2 methods to encode/decode from long <-> String
String s = encode( range, l );
and
long l = decode( range, s );
So decode(range, encode(range, 123456789L)) == 123456789L
And if range is "0123456789" thats the usual way of encoding.
© Stack Overflow or respective owner