⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 licensefactory.java

📁 请认真阅读您的文件包然后写出其具体功能(至少要20个字)。
💻 JAVA
字号:
package com.richeninfo.license;

import java.util.*;
import com.richeninfo.crypt.*;
import java.util.zip.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: </p>
 * @author xiaolie
 * @version 1.0
 */

public class LicenseFactory {

    public LicenseFactory() {
    }

	public String createPublicKey() throws Exception {
           Random random = new Random(System.currentTimeMillis());
           StringBuffer sb = new StringBuffer(16);
           for (int i = 0; i < 16; i++) {
               int k = random.nextInt();
               k = Math.abs(k);
               byte b = (byte)(k % 15 + 65);
               char c = (char)b;
               sb.append(c);
           }
           return sb.toString();
    }

    public String getSn(String pubKey) throws Exception {
        return LicenseKeyPair.getSn(pubKey, "");
    }


    public static void main(String[] args) throws Exception {
        LicenseFactory licenseFac = new LicenseFactory();
        if (args.length == 1) {
            String pubKey = args[0];
            if (pubKey.length() == 16) {
                String sn = licenseFac.getSn(pubKey);
                System.out.println("sn:" + sn);
            } else {
                System.out.println("key size must be 16");
            }
            return;
        }
        if (args.length < 4) {
            System.out.println("Usage: java com.richeninfo.license.LicenseFactory pubKey demotime groupsum usersum \n" +
                               "\t pubKey: public key" +
                               "\tdemotime: 0000-9999 the day's of app demo version can use, 0000 meaning no limited \n" +
                               "\tgroupsum: 0000-9999 the max group number of app can contain, 0000 meaning no limited \n" +
                               "\tusersum: 0000-9999 the max user number of app can contain, 0000 meaning no limited \n");
            return;
        }
        String pubKey = args[0];
        String params = args[1] + args[2] + args[3];
        System.out.println("params=" + params);
        CRC32 crc = new CRC32();
        crc.update(params.getBytes());
        long crcValue = crc.getValue();
        String sCrcValue = Long.toString(crcValue);

        //System.out.println("crcValue=" + crcValue + " b=" + Long.toString(crcValue));
        if (pubKey.length() == 16) {
            String sn1 = licenseFac.getSn(pubKey);
            StringBuffer sn2 = new StringBuffer(50);
            for (int i = 0; i < 12; i++) {
                char c = (char)((int)sn1.charAt(i) + (int)(params.charAt(i) - '0'));
                sn2.append(c);
            }
            int m = sCrcValue.length();
            m = (m < 12)?m:12;
            for (int i = 0; i < sCrcValue.length(); i++) {
                char c = (char)((int)sn1.charAt(12 + i) + (int)(sCrcValue.charAt(i) - '0'));
                sn2.append(c);
            }
            for (int i = m; i < 12; i++) {
                sn2.append(sn1.charAt(12 + i));
            }
            System.out.println("sn:" + sn2);
        } else {
            System.out.println("Usage: java com.richeninfo.license.LicenseFactory pubKey demotime groupsum usersum \n" +
                               "\t pubKey: public key" +
                               "\tdemotime: 0000-9999 the day's of app demo version can use, 0000 meaning no limited \n" +
                               "\tgroupsum: 0000-9999 the max group number of app can contain, 0000 meaning no limited \n" +
                               "\tusersum: 0000-9999 the max user number of app can contain, 0000 meaning no limited \n");
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -