首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

算法有关问题:这段程序怎么加密的

2011-11-21 
算法问题:这段程序如何加密的?//有无办法写个算号器?publicclassASTPrimaryCheck{privatestaticfinalStrin

算法问题:这段程序如何加密的?
//有无办法写个算号器?
public   class   ASTPrimaryCheck
{

private   static   final   String   DT   =   "dt ";
private   static   final   String   PK   =   "pk ";
private   static   final   String   USER   =   "us ";
private   static   final   String   TRY_LABEL   =   "Try   FDT ";
private   static   final   String   EXPIRED_LABEL   =   "Use   Restricted ";
private   static   boolean   valid   =   true;
private   static   boolean   checked   =   false;

public   ASTPrimaryCheck()
{
}

public   static   void   check()
{
if   (checked)
return;
checked   =   true;
if   (hasSerial())
{
checkSerial();
return;
}
String   pd   =   FDTUIPlugin.getPluginDirectory();
File   f   =   new   File((new   StringBuilder(String.valueOf(pd))).append( "icons/imageIndexByte ").toString());
boolean   hasDate   =   hasInstallDate();
if   (!f.exists()   &&   !hasDate)
{
valid   =   false;
openDialog(getTimeUpText(),   "Use   Restricted ");
return;
}
if   (f.exists())
f.delete();
long   installDate   =   -1L;
if   (hasDate)
installDate   =   getInstallDate();
else
installDate   =   createInstallData();
if   (installDate   ==   -1L)
{
valid   =   false;
openDialog(getTimeUpText(),   "Use   Restricted ");
return;
}
long   currentDate   =   System.currentTimeMillis();
long   diff   =   currentDate   -   installDate;
long   diffDay   =   diff   /   1000L   /   60L   /   60L   /   24L;
long   daysLeft   =   30L   -   diffDay;
if   (daysLeft   >   30L   ||   installDate   ==   -2L   ||   daysLeft   <=   0L)
{
ConfigurationSupport.storeObject( "dt ",   new   Long(-2L));
valid   =   false;
openDialog(getTimeUpText(),   "Use   Restricted ");
}   else
{
openDialog(getTimeLeftText(daysLeft),   "Try   FDT ");
}
}

public   static   boolean   isValid()
{
return   valid;
}

public   static   boolean   storeKey(String   userName,   String   key)
{
if   (!ConfigurationSupport.storeObject( "us ",   userName))
return   false;
if   (!ConfigurationSupport.storeObject( "pk ",   key))
{
return   false;
}   else
{
valid   =   true;
return   true;
}
}

private   static   boolean   hasSerial()
{
return   ConfigurationSupport.hasObject( "us ")   &&   ConfigurationSupport.hasObject( "pk ");
}

private   static   void   checkSerial()
{
try
{
String   key   =   (String)ConfigurationSupport.readObject( "pk ");


String   user   =   (String)ConfigurationSupport.readObject( "us ");
prowv(user,   key);
}
catch   (Exception   )
{
valid   =   false;
openDialog(getIllegalKeyText(),   "Use   Restricted ");
}
}

private   static   long   createInstallData()
{
long   in_date   =   System.currentTimeMillis();
ConfigurationSupport.storeObject( "dt ",   new   Long(in_date));
return   getInstallDate();
}

private   static   long   getInstallDate()
{
long   result   =   ((Long)ConfigurationSupport.readObject( "dt ")).longValue();
return   result;
JVM   INSTR   pop   ;
return   -1L;
}

private   static   boolean   hasInstallDate()
{
return   getInstallDate()   !=   -1L;
}

public   static   void   openDialog(final   String   message,   final   String   label)
{
PlatformUI.getWorkbench().getDisplay().asyncExec(new   Runnable()   {

private   final   String   val$label;
private   final   String   val$message;

public   void   run()
{
org.eclipse.swt.widgets.Shell   shell   =   PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
StartDialog   d   =   new   StartDialog(shell,   0);
d.setOKText(label);
d.open(message);
}


{
label   =   s;
message   =   s1;
super();
}
});
}

private   static   String   getTimeLeftText(long   daysLeft)
{
return   (new   StringBuilder( "Thank   you   for   testing   FDT.\n\nYou   have   ")).append(daysLeft).append( "   days   left   to   test   FDT.\nAfter   that   time   FDT   will   run   restricted.\n\nVisit   the   FDT   Website   at   http://fdt.powerflasher.com\nto   get   more   information   on   how   to   get   a   FDT   Product   Key. ").toString();
}

private   static   String   getTimeUpText()
{
return   "The   FDT   Trial   is   expired.\n\nFDT   will   run   in   restrict   mode   now.\nPlease   enter   a   FDT   Product   key.\n\nVisit   the   FDT   Website   at   http://fdt.powerflasher.com\nto   get   more   information   on   how   to   get   a   FDT   Product   Key. ";
}

private   static   String   getIllegalKeyText()
{
return   "The   found   FDT   product   Key   is   not   valid.\nFDT   will   run   in   restrict   mode   now.\nPlease   enter   the   FDT   Product   key   again.\nThis   problem   may   occure   when   the   eclipse   folder   location   has   changed. ";
}

public   static   void   prowv(String   pn,   String   pk)
throws   Exception
{
int   l   =   pk.length();
char   s[]   =   pk.toCharArray();
String   vars[]   =   new   String[l];


for   (int   i   =   0;   i   <   l;   i++)
vars[i]   =   " ";

for   (int   i   =   0;   i   <   l;   i++)
{
for   (int   y   =   0;   y   <   l;   y++)
vars[y]   =   (new   StringBuilder(String.valueOf(s[y]))).append(vars[y]).toString();

Arrays.sort(vars);
}

for   (int   i   =   0;   i   <   l;   i++)
if   (vars[i].charAt(l   -   1)   ==   'z ')
pk   =   vars[i].substring(0,   l   -   1);

l   =   pk.length()   /   2;
byte   id[]   =   new   byte[l];
int   j   =   0;
for   (int   i   =   0;   i   <   l;   i++)
{
char   c   =   pk.charAt(j++);
int   sp   =   c   <   '0 '   ||   c   >   '9 '   ?   c   <   'a '   ||   c   >   'z '   ?   (c   -   65   &   7)   +   10   :   (c   -   97   &   7)   +   10   :   c   -   48;
c   =   pk.charAt(j++);
int   kp   =   c   <   '0 '   ||   c   >   '9 '   ?   c   <   'a '   ||   c   >   'z '   ?   (c   -   65   &   7)   +   10   :   (c   -   97   &   7)   +   10   :   c   -   48;
id[i]   =   (byte)(sp   < <   4   |   kp);
}

j   =   0;
for   (int   i   =   0;   i   <   27;   i++)
if   (i   <   5   ||   i   >   8)
id[i]   ^=   id[j++   %   4   +   5];

byte   prod   =   0;
for   (int   i   =   0;   i   <   26;   i++)
prod   ^=   id[i];

if   (prod   !=   id[26])
throw   new   Exception( " ");
String   dis   =   (new   StringBuilder( "xz874hfdu ")).append(pn).toString();
byte   di[]   =   dis.getBytes( "utf-8 ");
MessageDigest   md5   =   MessageDigest.getInstance( "MD5 ");
di[0]   =   id[5];
di[1]   =   id[6];
di[2]   =   id[7];
di[3]   =   id[8];
byte   kd2[]   =   md5.digest(di);
for   (int   i   =   0;   i   <   5;   i++)
if   (id[i]   !=   kd2[i])
throw   new   Exception( "key   error ");

}

}

[解决办法]
看了一下,发表一下观后感:真是……………………长!
[解决办法]
看来我还要多学习 只看懂一部分.如果有谁会写请再发一版让我学习学习.
[解决办法]
这段代码是干什么的?

[解决办法]
刚起步~`看不太懂`~
------解决方案--------------------


1.5版本的,本人已经写出的keygen.
3.0 的现在搞不明白了。

热点排行