package com.zhangwoo.spider.common;
import java.io.UnsupportedEncodingException;
import com.meiya.common.encrypt.RSABuilder;
public class MessageServerCoder {
public static String[] keys = new String[] {
"65537",
"119095462634741964324355910493568039420885276438910071756048819526760006432501232179657393516109953903723308234590275673898671491223659550041136368691686513371223760955488588079501257335745347521033202920071657686214660648901407766547905679030685564937077732539638036430290036113165791480029536921250935798327",
"23467641247921902547945927157391056366347444343379841412600736307255118834693698404994058011002089578599612471451223279257937403873572782233413721489913168897835597538656382065823620483700749845759202674069126802759827242990465948569031122794135920488375018510544138974426585678970037783902823874174201059425",
"12200874031885517368335166862225563130355875459757162644782242571833387635715623085931289252955320907505610616380387850350380647277237723286254704307867103",
"9761223853594446726059350453988895548229001566482525834704152451365934542774839285235231034141206178466968859720471199547460669407362668696985134624304809" };
public static String decode(String msg){
try {
msg = new RSABuilder().Dec_RSA(msg, keys[2], keys[1]);
if(!msg.substring(0,8).equals("zhangwoo")){
return "";
}
} catch (UnsupportedEncodingException e) {}
return msg.substring(8);
}
public static String encode(String msg){
try {
msg = new RSABuilder().Enc_RSA("zhangwoo"+msg, keys[2], keys[1]);
} catch (UnsupportedEncodingException e) {}
return msg;
}
}