//**************************************************************************** // $Module type: Package // $Module name: xxSoftwareKey.pkg // $Author : Nils G. Svedmyr // Created : 2003-04-28 @ 16:26 // // COPYRIGHT (c) 2003-2006 RDC Tools International // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; version 2 // of the License. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; (See the GPL.txt file in the Help directory) if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Description : // // $Rev History: // 2003-04-28 Module header created // 2006-11-08 Removed everything that had to do with SoftwareKey copy protection. // //**************************************************************************** //Use KeyLib.h // Define statements (constants). Also incl. C_RDCKRY et al used here and elsewhere. Use vWin32fh.pkg Use GetSystemInfo.pkg Define cs_PwInit For ("RO9"+string("2SV5")+String("5NIO")+String("8ED0")+String("2MYR")) Define c1 For 52845 // Do not change Define c2 For 22719 // Do not change #COMMAND CHECK_APPLICATION R R !A [] $2ec !1 !2 #ENDCOMMAND Function TodaysDateMilitary Global Returns String Integer iDateFormat String sRetval Date dToday Get_Attribute DF_Date_Format To iDateFormat // Save the current format Set_Attribute DF_Date_Format To DF_DATE_MILITARY // Set to YYYY-MM-DD Sysdate dToday Move dToday To sRetval Set_Attribute DF_Date_Format To iDateFormat // Reset the date format. Function_Return sRetval End_Function // TodaysDateMilitary Function fiXor Global UChar iA UChar iB Returns UChar Boolean bA7 bA6 bA5 bA4 bA3 bA2 bA1 bA0 Boolean bB7 bB6 bB5 bB4 bB3 bB2 bB1 bB0 Boolean bC7 bC6 bC5 bC4 bC3 bC2 bC1 bC0 Move (iA Iand 64) To bA6 Move (iA Iand 32) To bA5 Move (iA Iand 16) To bA4 Move (iA Iand 8) To bA3 Move (iA Iand 4) To bA2 Move (iA Iand 2) To bA1 Move (iA Iand 1) To bA0 Move (iB Iand 64) To bB6 Move (iB Iand 32) To bB5 Move (iB Iand 16) To bB4 Move (iB Iand 8) To bB3 Move (iB Iand 4) To bB2 Move (iB Iand 2) To bB1 Move (iB Iand 1) To bB0 Move ((bA7 Or bB7 ) And Not(bA7 =bB7 )) To bC7 Move ((bA6 Or bB6 ) And Not(bA6 =bB6 )) To bC6 Move ((bA5 Or bB5 ) And Not(bA5 =bB5 )) To bC5 Move ((bA4 Or bB4 ) And Not(bA4 =bB4 )) To bC4 Move ((bA3 Or bB3 ) And Not(bA3 =bB3 )) To bC3 Move ((bA2 Or bB2 ) And Not(bA2 =bB2 )) To bC2 Move ((bA1 Or bB1 ) And Not(bA1 =bB1 )) To bC1 Move ((bA0 Or bB0 ) And Not(bA0 =bB0 )) To bC0 Function_Return ((128*bC7)+(64*bC6)+(32*bC5)+(16*bC4)+(8*bC3)+(4*bC2)+(2*bC1)+bC0) End_Function // fiXor Function CmNewEnKry Global String sInput Integer iKey Returns String Integer i Decimal nbKeyLoop nbKey nbChar nbC1 nbC2 Bigint ibKey String sOutput Move (Trim(sInput) - String(cs_PwInit)) To sInput Move iKey To nbKeyLoop Move iKey To nbKey Move c1 To nbC1 Move c2 To nbC2 For i From 1 To (Length(sInput)) Move (nbKey/256) To ibKey Move (nbKey-(ibKey*256)) To iKey Move (sOutput+Character(fiXor(Ascii(Mid(sInput,1,i)),iKey))) To sOutput Move (Ascii(Mid(sOutput,1,i))) To nbChar Move (((nbChar+nbKeyLoop)*nbC1)+nbC2) To nbKeyloop Move (nbKeyLoop/256) To nbKey Loop Function_Return sOutput End_Function // CmNewEnKry Function CmNewDeKry Global String sInput Integer iKey Returns String Integer i Decimal nbKeyLoop nbKey nbChar nbC1 nbC2 Bigint ibKey String sOutput Move iKey To nbKeyLoop Move iKey To nbKey Move c1 To nbC1 Move c2 To nbC2 For i From 1 To (Length(sInput)) Move (nbKey/256) To ibKey Move (nbKey-(ibKey*256)) To iKey Move (sOutput+Character(fiXor(Ascii(Mid(sInput,1,i)),iKey))) To sOutput Move (Ascii(Mid(sInput,1,i))) To nbChar Move (((nbChar+nbKeyLoop)*nbC1)+nbC2) To nbKeyloop Move (nbKeyLoop/256) To nbKey Loop Move (Replace(cs_PwInit, sOutput, "")) To sOutput Function_Return sOutput End_Function // CmNewDeKry // Takes a string as argument. // Returns: True if all is numeric. // False if string contains any other than digits. Function IsNumeric Global String sValue Returns Boolean Boolean bOk Integer iLen iCount String sChar Move (Trim(sValue)) To sValue Move (Length(sValue)) To iLen If Not iLen Function_Return False Move (True) To bOk For iCount From 1 To iLen Move (Mid(sValue, 1, iCount)) To sChar If Not ("-0123456789" Contains sChar) Move (False) To bOk If Not bOk Break Loop // For iCount from 1 to lLen Function_Return bOk End_Function // IsNumeric // Takes a string as argument. // Returns: True if all is date. // False if string contains any other than digits. Function IsDate Global String sValue Returns Boolean Boolean bOk Integer iLen iCount String sChar Move (Trim(sValue)) To sValue Move (Length(sValue)) To iLen If Not iLen Function_Return False Move (True) To bOk For iCount From 1 To iLen Move (Mid(sValue, 1, iCount)) To sChar If Not ("/-0123456789" Contains sChar) Move (False) To bOk If Not bOk Break Loop // For iCount from 1 to lLen Function_Return bOk End_Function // IsDate // Arguments: String with Characters/words separated with the sSep character // Integer is the posisition of the substring. // Returns: The substring denoted by the iField parameter. // Note: The string should have no leading or trailing "sSep" characters. Function ExtractVal Global String sString String sSep Integer iField Returns String Integer iStart iEnd iCount String sRetval If Not (sString Contains sSep) Function_Return sString // Nothing to do. Move (sSep - String(sString) - String(sSep)) To sString For iCount From 1 To (iField - 1) Move (Replace(sSep, sString, "")) To sString Loop // For iCount from 1 to iField Move (Pos(sSep, sString)) To iStart Move (Replace(sSep, sString, "")) To sString Move (Pos(sSep, sString)) To iEnd //Showln "iStart = " iStart " iEnd = " iEnd Move (Mid(sString, (iEnd - iStart), iStart)) To sRetval Function_Return sRetval End_Function // ExtractVal