Control software trial period source code (three hours of novice) (original)

xiaoxiao2021-03-05  23

Principles: By judging the number of logins of the user and setting the expiration time and the system existing time comparison, there is an illegal prompt software expires. The string is compared by MD5. I think I started set TXT to hide the mode, and I will delete the TXT file with a trial period, you should do a better effect, welcome to discuss! MSN: YUN15291LI@hotmail.com QQ: 17664554 package admin.control; import java.io. *; import java.security.MessageDigest; import admin.md5; import java.util. *; / ** *

Title: ***** System *

Description: **** System *

Copyright: CopyRight (C) 2004 *

Company: Beijing University Software College * @Author Yunguang * @version 1.0 * / public class controllerid {private final string registernumber; // Encrypted raw string private string md5number; // MD5 encrypted string private string writecontent; / / Need to write text int logintimeslimit; // Login limit private static int logintimeStrue; // User's actual landing number private md5 md5object; // Instantiate MD5 Object Private Calendar Cal; // Date Time Class Private Int ORDERTIME ; // Setting the system expiration time // Configuration method for initialization assignment public controlvalid () {registernumber = "The correct verification string you want to enter"; md5object = new md5 (); logintimeslimit = 99; logintimeStrue = 0; logintimeStrue = 0; logintimeStrue = 0; WriteContent = NULL; CAL = Calendar.GetInstance (); ORDERTIME = 0;} // Return the MD5 encrypted string public string ReturnMd5String () {Try {// Get MD5Number = MD5Object.md5 (REGISTERNUMBER); return md5Number;} catch (Exception e) {return null;}} // specified text string written public void writeFile () {try {string returnFileString; int returnLastLoginTimes = 0; // Calendar cal = Calendar .GetInstance (); // Test acquisition system time int currentdate = caver.get (cal.Year) 1) Cal.Get (Cal.day) _Of_month); //system.out.println (currentdate); // Need to write text file string string returnitdate = this.readfile ("initdate.txt"); Ordertime = Integer.Parseint (ReturnInInitdate); ReturnFileString = THIS .readfile ("ControlValid.txt"); // Get the position of the wrap INT POS = returnFileString.indexof ("/ n"); if (POS! = -1) {ReturnLastLogintimes = Integer.Parseint (ReturnFileString.Substring (POS 1, POS 3));} logintimeStrue = ReturnLastLogintimes; this.setLogintimeStrue (); // Depending on the date and user login number to determine the written string IF (this.getLogintimeStrue ()

this.getlogintimeStrue (); WriteContent = this.returnMd5String () "/ r" this.getLogintimeStrue ();} else {// randomly generate a number to enter random ranint = new random (); // int randomint = WriteContent = String.Valueof (ranint.nextint (10000000)) "/ r" this.getlogintimeStrue ();} // Write the encrypted string to file file f = new file ("controlvalid.txt" ); if (f.exists (!)) {f.createNewFile ();} DataOutputStream outFile = new DataOutputStream (new BufferedOutputStream (new FileOutputStream (f))); byte [] byteWriteContent = writeContent.getBytes (); outFile.write (ByteWriteContent); Outfile.close ();} catch (exception e) {system.out.println (E.GetMessage ());}} // Read Data in the specified text PUBLIC STRINGETFILE (STRING FileName) {String sLine = "", sResult = ""; boolean testFirstLine = true; try {DataInputStream inFile = new DataInputStream (new BufferedInputStream (new FileInputStream (fileName))); while (! (sLine = inFile.readLine ()) = null) { IF (TestfirstLine) {SResult = sline; testfirstline = false;} else {sResult = "/ n" sline;}} in File.close (); return sResult;} catch (Exception e) {return null;}} // Returns the text string registered string comparison public boolean ContractRegisterString () {String returnFileString; String md5String; String returnMd5String = " "; INT i = 0; returnfilestring = this.readfile (" controlvalid.txt "); // Get the position of the wrap INT POS = ReturnFileString.indexOf (" / n "); if (pOS! = -1) {ReturnMd5String = returnFileString.substring (0, pos);} md5String = this.returnMd5String (); //System.out.println(returnFileString); // get through MD5 encrypted string if (md5String.equals (returnMd5String)) {return True;

转载请注明原文地址:https://www.9cbs.com/read-37128.html

New Post(0)