import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;
InputStream inputStream= System.in; Reader reader=new InputStreamReader(inputStream); BufferedReader br=new BufferedReader(reader) ; while((str=br.readLine())!=null){ String result = new String(Base64.encodeBase64(DigestUtils.md5(str.getBytes("UTF-8"))),"UTF-8"); System.out.println(result); } br.close();