Skip to content

Instantly share code, notes, and snippets.

@Ke-
Created January 7, 2015 06:46
Show Gist options
  • Select an option

  • Save Ke-/30ea9fb28670e8403536 to your computer and use it in GitHub Desktop.

Select an option

Save Ke-/30ea9fb28670e8403536 to your computer and use it in GitHub Desktop.
integer->encodeBase64Short, string->decodeBase64Short
/*
1: AQ
62: Pg
100: Z
1000: 6AM
10000: ECc
100000: oIYB
1000000: QEIP
10000000: gJaY
1000000000: AMqaOw
100000000000: AOh2SBc
100000000000000: AEB6EPN
9223372036854775807: /////////38
18446744073709551615: //////////8
*/
define integer->encodeBase64Short => {
local(out) = bytes->import64bits(self) & encodebase64->asstring
#out->removetrailing('=') & removetrailing('A')
return #out
}
define string->decodeBase64Short => {
return decode_base64(self + ('A' * (11 - self->size)) + '=')->export64bits
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment