制作一个CDKey之类的东西,验证你们的服务器,而且加密算法要严格。
解决方案 »
- 奇怪赋值问题???求解
- Error listenerStart
- wap网站的歌曲下载代码怎么写
- 新手求助:怎样把在windows下编译好的JAVA程序拿到别的机器上执行?对另一台机器有什么要求?
- struts中<html:errors/>问题
- 小弟刚刚学习了Servlet的会话跟踪,有一点体会,怕有错,望各位指正并详解!
- 一个有关数据传输的问题,还请高手指点!
- 我想通过JB中做一个EJB,其中EJB链接数据库用Weblogic的链接池
- EJB的一个普通路径问题如何解决???"mod1.ejbgrpx": <2002-6-9 下午04时27分26秒> <Warning> <EJB> <EJB Deployment: Cart has a class
- Spring声明式事务问题(虚心请教)
- JFrame中实现彩信播放功能
- 请问下如何把类的枚举值显示在jsp里面,并且提交后自动mapping
private static String getMACAddress(InetAddress ia) throws Exception {
// 获得网络接口对象(即网卡),并得到mac地址,mac地址存在于一个byte数组中。
byte[] mac = NetworkInterface.getByInetAddress(ia).getHardwareAddress();
// 下面代码是把mac地址拼装成String
StringBuffer sb = new StringBuffer();
for (int i = 0; i < mac.length; i++) {
if (i != 0) {
sb.append("-");
}
// mac[i] & 0xFF 是为了把byte转化为正整数
String s = Integer.toHexString(mac[i] & 0xFF);
sb.append(s.length() == 1 ? 0 + s : s);
}
// 把字符串所有小写字母改为大写成为正规的mac地址并返回
return sb.toString().toUpperCase();
}
用MAC 地址,然后用RAS 加密
BufferedReader in=
new BufferedReader(new InputStreamReader(new FileInputStream(path+"Lh_AIG_Enc_RSA.dat")));
String ctext=in.readLine();
BigInteger c=new BigInteger(ctext);
//获取私钥
FileInputStream f=new FileInputStream(path+"RSA_priv.dat");
ObjectInputStream b=new ObjectInputStream(f);
RSAPrivateKey prk=(RSAPrivateKey)b.readObject( );
//获取私钥的参数d,n
BigInteger d=prk.getPrivateExponent();
BigInteger n=prk.getModulus();
//System.out.println("d= "+d);
//System.out.println("n= "+n);
//解密明文
BigInteger m=c.modPow(d,n);
// System.out.println("m= "+m);
//计算明文对应的字符串并输出。
byte[] mt=m.toByteArray();
System.out.println("PlainText is ");
for(int i=0;i<mt.length;i++){
System.out.print((char) mt[i]);
}