2128: base64解密
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 350 Solved: 155
SubmitStatusWeb Board
字符,只有两位0,拿出来,前面补6个0,则是00000000,对应表得字符A。
由于还有2个6位的字节没显示,则用两个=字符补充
那么字符0的Base64编码为MA==
现在蛋蛋给了你一段加密后的Base64密文,他说题意隐藏在密文里面,如果你知道了题意,就肯定可以做出本题。密文如下:
d2hhdCBpcyB0aGUgcmVtYWluZGVyIHdoZW4gdGhlIG51bWJlciBpcyBkaXZpZGVkIGJ5IDIwMTc/
Input
第一行一个整数t,代表有t组数据,每组数据输入一个整数x,0<=x<=2^31-1
Output
输出一个整数x,x为答案
Sample Input
3
0
1
2016
Sample Output
0
1
2016
HINT
java base64 加/解密~
实现代码:
package One;
import java.io.IOException;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
@SuppressWarnings("unused")
public class Two {
/**
* @param args
*/
public static void javaBase64(String key) {
// TODO Auto-generated method stub
@SuppressWarnings("unused")
BASE64Encoder encoder = new BASE64Encoder(); // 加密
String encodeBase64 = encoder.encode(key.getBytes());
System.out.println("加密后 : " + encodeBase64);
BASE64Decoder decoder = new BASE64Decoder();
try{
byte[] decodeBase64 = decoder.decodeBuffer(encodeBase64);
System.out.println("解密后 : " + new String(decodeBase64));
}catch(IOException e){
e.printStackTrace();
}
}
public static void main(String[] args){
String message = "666";
javaBase64(message);
}
}