10

Possible Duplicate:
Base64 encoder and decoder

I am trying to encode a Url with Base64. Is there any way to encode it with Base64 in java/android?

I need something similar to base64_encode() function in PHP.

Community
  • 1
  • 1
Kalimah
  • 11,217
  • 11
  • 43
  • 80
  • Is your input a string? Due to your comment, it may well be, and in that case, the function you're looking for will not be exactly the same as `base64_encode` since strings are usually sequences of bytes in PHP and UTF-16 in Java. This is why Android's Base64 requires byte arrays as input to the encoding function. – Peter O. Oct 07 '11 at 13:47
  • Input is string. The input was not an issue as I could convert the string easily suing getBytes(). However, outputting the result as a string was hard. – Kalimah Oct 07 '11 at 13:52
  • duplicate of http://stackoverflow.com/q/4322182/808940 – Moog Oct 08 '11 at 12:53
  • I was not aware of the duplicate. Sorry. – Kalimah Oct 09 '11 at 22:23

1 Answers1

19

Base64 is part of the Android SDK from API level 8 onwards.

Graham Borland
  • 60,055
  • 21
  • 138
  • 179