「java」Base64Encoder/Base64Decoderを使うコード

javaコード
package com.startnews.encoder;
import java.io.IOException;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

public class Base64 {
public static void main(String[] args) {
try {
String name=" 管理者";
String pwd="管理ユーザのパスワード";
BASE64Encoder en=new BASE64Encoder();
name=en.encode(name.getBytes(“utf-8"));
pwd=en.encode(pwd.getBytes(“utf-8″));
System.out.println(name+","+pwd);

BASE64Decoder den=new BASE64Decoder();
name=new String(den.decodeBuffer(name),"utf-8″);
pwd=new String(den.decodeBuffer(pwd),"utf-8″);
System.out.println(name+","+pwd);
} catch (IOException e) {
e.printStackTrace();
}
}
}

Java

Posted by arkgame