📄 barcodelicensekey.java
字号:
package com.bokai.barcodes;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
class BarcodeLicenseKey
{
BarcodeLicenseKey()
{
}
private static char[] binaryToPrintableAZ(byte abyte0[])
{
char ac[] = new char[abyte0.length];
for(int j = 0; j < abyte0.length; j++)
{
int i = 0xf & abyte0[j];
ac[j] = (char)(65 + i % 26);
}
return ac;
}
private static synchronized String encrypt(String s)
throws NoSuchAlgorithmException, UnsupportedEncodingException
{
MessageDigest messagedigest = null;
try
{
messagedigest = MessageDigest.getInstance("SHA");
}
catch(NoSuchAlgorithmException nosuchalgorithmexception)
{
throw nosuchalgorithmexception;
}
messagedigest.update(stringToBytes(s));
byte abyte0[] = messagedigest.digest();
return new String(binaryToPrintableAZ(abyte0));
}
public static String generateKey(String s, String s1, String s2, int i, int j, int k)
throws NoSuchAlgorithmException, UnsupportedEncodingException
{
if(i != 0x263fc)
return null;
StringBuffer stringbuffer = new StringBuffer(s);
stringbuffer.append('c');
stringbuffer.append('1');
stringbuffer.append('u');
stringbuffer.append('0');
stringbuffer.append('p');
stringbuffer.append('5');
stringbuffer.append('e');
stringbuffer.append('8');
stringbuffer.append('r');
stringbuffer.append('0');
stringbuffer.append('t');
stringbuffer.append('i');
stringbuffer.append('n');
stringbuffer.append('o');
stringbuffer.append(s1);
if(s2.length() > 0)
{
stringbuffer.append(';');
stringbuffer.append(s2);
}
String s3 = "";
try
{
s3 = encrypt(stringbuffer.toString());
}
catch(NoSuchAlgorithmException nosuchalgorithmexception)
{
throw nosuchalgorithmexception;
}
catch(UnsupportedEncodingException unsupportedencodingexception)
{
throw unsupportedencodingexception;
}
return s3;
}
private static byte[] stringToBytes(String s)
{
char ac[] = s.toCharArray();
byte abyte0[] = new byte[ac.length * 2];
for(int i = 0; i < ac.length; i++)
{
abyte0[i * 2] = (byte)ac[i];
abyte0[i * 2 + 1] = (byte)(ac[i] >> 8);
}
return abyte0;
}
static String stringToUnicodeEscapes(String s)
{
StringBuffer stringbuffer = new StringBuffer();
for(int i = 0; i < s.length(); i++)
{
int j = 0xffff & s.charAt(i);
if((j & 0xff80) != 0)
{
stringbuffer.append("\\u");
String s1 = Integer.toHexString(j >> 12 & 0xf);
stringbuffer.append(s1.substring(0, 1));
s1 = Integer.toHexString(j >> 8 & 0xf);
stringbuffer.append(s1.substring(0, 1));
s1 = Integer.toHexString(j >> 4 & 0xf);
stringbuffer.append(s1.substring(0, 1));
s1 = Integer.toHexString(j & 0xf);
stringbuffer.append(s1.substring(0, 1));
} else
{
stringbuffer.append(s.charAt(i));
}
}
return stringbuffer.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -