Here you can find the source of encodeString(String str)
Parameter | Description |
---|---|
str | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static String encodeString(String str) throws IOException
//package com.java2s; import java.io.IOException; import sun.misc.BASE64Encoder; public class Main { /**// w ww .j a v a 2 s . c o m * Encode a string using Base64 encoding. Used when storing passwords * as cookies. * * This is weak encoding in that anyone can use the decodeString * routine to reverse the encoding. * * @param str * @return String * @throws IOException */ public static String encodeString(String str) throws IOException { BASE64Encoder encoder = new BASE64Encoder(); String encodedStr = encoder.encodeBuffer(str.getBytes()); return (encodedStr.trim()); } }