encode and decode Base64 with scala

Download and install scala

start scala console

C:\scala-2.8.1.final\bin>scala
Welcome to Scala version 2.8.1.final (Java HotSpot(TM) Client VM, Java 1.6.0_24).
Type in expressions to have them evaluated.
Type :help for more information.

encode

scala> new sun.misc.BASE64Encoder().encode( "myClearTextPW".getBytes())
res0: java.lang.String = bXlDbGVhclRleHRQVw==

decode

scala> new String(new sun.misc.BASE64Decoder().decodeBuffer("bXlDbGVhclRleHRQVw=="))
res1: java.lang.String = myClearTextPW

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Log Out / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Log Out / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Log Out / Ändern )

Verbinde mit %s


Follow

Get every new post delivered to your Inbox.