簡単なlisence生成プロセス_自分用

1999 ワード

自分で乗り換えるだけです.他のクラス依存性があります.
package test.yuan;

import java.util.Random;


/**
 * @author Syy
 *
 */
public class GenerateLisence {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String mac=MacAdressUtil.getMacAddress();
		System.out.println(mac);
		// -
		String[] macArray=mac.split("-");
		StringBuffer sb=new StringBuffer();
		for (String s:macArray){
			sb.append(s);
		}
		System.out.println(sb.toString());
		//sb.insert(2, 'a');
		//System.out.println(sb.toString());
		mac=sb.toString();
		// mac
		String cipherMac=CipherUtil.generatePassword(mac);
		System.out.println(cipherMac);
		System.out.println(sb.length());
		// lisence
		Random random=new Random(System.currentTimeMillis());
		int length=sb.length();
		System.out.println(" :");
		for(int i=0;i<length;i++){
			char randomChar=(char)(random.nextInt(20)+71);
			int randomIndex=random.nextInt(length+i+1);
			System.out.println(randomChar+","+randomIndex);
			sb.insert(randomIndex, randomChar);
			System.out.println(sb);
		}
		//lisence , 24 , lisence 
		// mac, mac , 
		System.out.println(sb.length());
		int index=sb.length();
		for(int i=0;i<index;i++){
			char c=sb.charAt(i);
			System.out.print(c+",");
			if(c>'F'){
				sb.deleteCharAt(i);
				index--;
				i--;
			}
		}
		System.out.println(sb.toString());
		String compMac=CipherUtil.generatePassword(sb.toString());
		System.out.println(compMac);
		if(compMac.equals(cipherMac)){
			System.out.println(" ");
		}else{
			System.out.println(" ");
		}
	}

}