Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Are you married to using Java? Python has an entire package dedicated just for this exact purpose. It'll even sanitize the encoding for you to be URL-safe.</p> <h3>Native Python solution</h3> <p>The standard module I'm recommending is <code>base64</code>, which converts arbitrary stings of chars into sanitized base64 format. You can use it in conjunction with the <code>pickle</code> module, which handles conversion from lists of longs (actually arbitrary size) to a compressed string representation.</p> <p>The following code should work on any vanilla installation of Python:</p> <pre><code>import base64 import pickle # get some long list of numbers a = (854183415,1270335149,228790978,1610119503,1785730631,2084495271, 1180819741,1200564070,1594464081,1312769708,491733762,243961400, 655643948,1950847733,492757139,1373886707,336679529,591953597, 2007045617,1653638786) # this gets you the url-safe string str64 = base64.urlsafe_b64encode(pickle.dumps(a,-1)) print str64 &gt;&gt;&gt; gAIoSvfN6TJKrca3S0rCEqMNSk95-F9KRxZwakqn3z58Sh3hYUZKZiePR0pRlwlfSqxGP05KAkNPHUo4jooOSixVFCdK9ZJHdEqT4F4dSvPY41FKaVIRFEq9fkgjSvEVoXdKgoaQYnRxAC4= # this unwinds it a64 = pickle.loads(base64.urlsafe_b64decode(str64)) print a64 &gt;&gt;&gt; (854183415, 1270335149, 228790978, 1610119503, 1785730631, 2084495271, 1180819741, 1200564070, 1594464081, 1312769708, 491733762, 243961400, 655643948, 1950847733, 492757139, 1373886707, 336679529, 591953597, 2007045617, 1653638786) </code></pre> <p>Hope that helps. Using Python is probably the closest you'll get from a 1-line solution.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload