diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e759b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,330 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ diff --git a/SKGL 2.0.5.2/Base/BaseConfiguration.cs b/SKGL 2.0.5.2/Base/BaseConfiguration.cs new file mode 100644 index 0000000..252f902 --- /dev/null +++ b/SKGL 2.0.5.2/Base/BaseConfiguration.cs @@ -0,0 +1,167 @@ +using System; +using System.Linq; +using System.Management; +using System.Net.NetworkInformation; +using System.Security; + +namespace SKGL.Base +{ + public abstract class BaseConfiguration + { + //Put all functions/variables that should be shared with + //all other classes that inherit this class. + // + //note, this class cannot be used as a normal class that + //you define because it is MustInherit. + + protected internal string _key = ""; + /// + /// The key will be stored here + /// + public virtual string Key + { + //will be changed in both generating and validating classe. + get { return _key; } + set { _key = value; } + } + + /// + /// + /// + /// + /// + /// + public virtual int MachineCode + { + get { return getMachineCode(); } + } + + [SecuritySafeCritical] + private static int getMachineCode() + { + // please see https://skgl.codeplex.com/workitem/2246 for a list of developers of this code. + + methods m = new methods(); + + ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_Processor"); + string collectedInfo = ""; + // here we will put the informa + foreach (ManagementObject share in searcher.Get()) + { + // first of all, the processorid + collectedInfo += share.GetPropertyValue("ProcessorId"); + } + + searcher.Query = new ObjectQuery("select * from Win32_BIOS"); + foreach (ManagementObject share in searcher.Get()) + { + //then, the serial number of BIOS + collectedInfo += share.GetPropertyValue("SerialNumber"); + } + + searcher.Query = new ObjectQuery("select * from Win32_BaseBoard"); + foreach (ManagementObject share in searcher.Get()) + { + //finally, the serial number of motherboard + collectedInfo += share.GetPropertyValue("SerialNumber"); + } + + // patch luca bernardini + if (string.IsNullOrEmpty(collectedInfo) | collectedInfo == "00" | collectedInfo.Length <= 3) + { + collectedInfo += getHddSerialNumber(); + } + + // In case we have message "To be filled by O.E.M." - there is incorrect motherboard/BIOS serial number + // - we should relay to NIC + if (collectedInfo.Contains("To be filled by O.E.M.")) + { + var nic = GetNicInfo(); + + if (!string.IsNullOrWhiteSpace(nic)) + collectedInfo += nic; + } + + return m.getEightByteHash(collectedInfo, 100000); + + } + + /// + /// Enumerate all Nic adapters, take first one, who has MAC address and return it. + /// + /// Function MUST! be updated to select only real NIC cards (and filter out USB and PPTP etc interfaces). + /// Otherwise user can run in this scenario: a) Insert USB NIC b) Generate machine code c) Remove USB NIC... + /// + /// MAC address of NIC adapter + [SecuritySafeCritical] + private static string GetNicInfo() + { + var nics = NetworkInterface.GetAllNetworkInterfaces(); + var mac = string.Empty; + + foreach (var adapter in nics.Where(adapter => string.IsNullOrWhiteSpace(mac))) + mac = adapter.GetPhysicalAddress().ToString(); + + return mac; + } + + /// + /// Read the serial number from the hard disk that keep the bootable partition (boot disk) + /// + /// + /// If succedes, returns the string rappresenting the Serial Number. + /// String.Empty if it fails. + /// + [SecuritySafeCritical] + private static string getHddSerialNumber() + { + // --- Win32 Disk + ManagementObjectSearcher searcher = new ManagementObjectSearcher("\\root\\cimv2", "select * from Win32_DiskPartition WHERE BootPartition=True"); + + uint diskIndex = 999; + foreach (ManagementObject partition in searcher.Get()) + { + diskIndex = Convert.ToUInt32(partition.GetPropertyValue("DiskIndex")); // should be DiskIndex + break; // TODO: might not be correct. Was : Exit For + } + + // I haven't found the bootable partition. Fail. + if (diskIndex == 999) + return string.Empty; + + // --- Win32 Disk Drive + searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive where Index = " + diskIndex.ToString()); + + string deviceName = ""; + foreach (ManagementObject wmi_HD in searcher.Get()) + { + deviceName = wmi_HD.GetPropertyValue("Name").ToString(); + break; // TODO: might not be correct. Was : Exit For + } + + + // I haven't found the disk drive. Fail + if (string.IsNullOrEmpty(deviceName.Trim())) + return string.Empty; + + // -- Some problems in query parsing with backslash. Using like operator + if (deviceName.StartsWith("\\\\.\\")) + { + deviceName = deviceName.Replace("\\\\.\\", "%"); + } + + // --- Physical Media + searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia WHERE Tag like '" + deviceName + "'"); + string serial = string.Empty; + foreach (ManagementObject wmi_HD in searcher.Get()) + { + serial = wmi_HD.GetPropertyValue("SerialNumber").ToString(); + break; // TODO: might not be correct. Was : Exit For + } + + return serial; + + } + + } +} diff --git a/SKGL 2.0.5.2/Generate.cs b/SKGL 2.0.5.2/Generate.cs new file mode 100644 index 0000000..d7bdf04 --- /dev/null +++ b/SKGL 2.0.5.2/Generate.cs @@ -0,0 +1,118 @@ +using SKGL.Base; +using System; + +namespace SKGL +{ + public class Generate : BaseConfiguration + { + //this class have to be inherited because of the key which is shared with both encryption/decryption classes. + + SerialKeyConfiguration skc = new SerialKeyConfiguration(); + methods m = new methods(); + Random r = new Random(); + public Generate() + { + // No overloads works with Sub New + } + public Generate(SerialKeyConfiguration _serialKeyConfiguration) + { + skc = _serialKeyConfiguration; + } + + private string _secretPhase; + /// + /// If the key is to be encrypted, enter a password here. + /// + + public string secretPhase + { + get { return _secretPhase; } + set + { + if (value != _secretPhase) + { + _secretPhase = m.twentyfiveByteHash(value); + } + } + } + /// + /// This function will generate a key. + /// + /// For instance, 30 days. + public string doKey(int timeLeft) + { + return doKey(timeLeft, DateTime.Today); // removed extra argument false + } + + /// + /// + /// + /// For instance, 30 days + /// Lock a serial key to a specific machine, given its "machine code". Should be 5 digits long. + /// + /// + public object doKey(int timeLeft, int useMachineCode) + { + return doKey(timeLeft, DateTime.Today, useMachineCode); + } + + /// + /// This function will generate a key. You may also change the creation date. + /// + /// For instance, 30 days. + /// Change the creation date of a key. + /// Lock a serial key to a specific machine, given its "machine code". Should be 5 digits long. + public string doKey(int timeLeft, System.DateTime creationDate, int useMachineCode = 0) + { + if (timeLeft > 999) + { + //Checking if the timeleft is NOT larger than 999. It cannot be larger to match the key-length 20. + throw new ArgumentException("The timeLeft is larger than 999. It can only consist of three digits."); + } + + if (!string.IsNullOrEmpty(secretPhase) | secretPhase != null) + { + //if some kind of value is assigned to the variable "secretPhase", the code will execute it FIRST. + //the secretPhase shall only consist of digits! + System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("^\\d$"); + //cheking the string + if (reg.IsMatch(secretPhase)) + { + //throwing new exception if the string contains non-numrical letters. + throw new ArgumentException("The secretPhase consist of non-numerical letters."); + } + } + + //if no exception is thown, do following + string _stageThree = null; + if (useMachineCode > 0 & useMachineCode <= 99999) + { + _stageThree = m._encrypt(timeLeft, skc.Features, secretPhase, useMachineCode, creationDate); + // stage one + } + else + { + _stageThree = m._encrypt(timeLeft, skc.Features, secretPhase, r.Next(0, 99999), creationDate); + // stage one + } + + //if it is the same value as default, we do not need to mix chars. This step saves generation time. + + if (skc.addSplitChar == true) + { + // by default, a split character will be addedr + Key = _stageThree.Substring(0, 5) + "-" + _stageThree.Substring(5, 5) + "-" + _stageThree.Substring(10, 5) + "-" + _stageThree.Substring(15, 5); + } + else + { + Key = _stageThree; + } + + //we also include the key in the Key variable to make it possible for user to get his key without generating a new one. + return Key; + + } + + + } +} diff --git a/SKGL 2.0.5.2/SKGL 2.0.5.2.csproj.vspscc b/SKGL 2.0.5.2/SKGL 2.0.5.2.csproj.vspscc deleted file mode 100644 index b6d3289..0000000 --- a/SKGL 2.0.5.2/SKGL 2.0.5.2.csproj.vspscc +++ /dev/null @@ -1,10 +0,0 @@ -"" -{ -"FILE_VERSION" = "9237" -"ENLISTMENT_CHOICE" = "NEVER" -"PROJECT_FILE_RELATIVE_PATH" = "" -"NUMBER_OF_EXCLUDED_FILES" = "0" -"ORIGINAL_PROJECT_FILE_PATH" = "" -"NUMBER_OF_NESTED_PROJECTS" = "0" -"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" -} diff --git a/SKGL 2.0.5.2/SKGL.cs b/SKGL 2.0.5.2/SKGL.cs index 54c98c1..78b689e 100644 --- a/SKGL 2.0.5.2/SKGL.cs +++ b/SKGL 2.0.5.2/SKGL.cs @@ -1,8 +1,7 @@ using System; -using System.Collections; -using System.Collections.Generic; -using System.Data; -using System.Diagnostics; +using System.Numerics; +using System.Security; + //Copyright (C) 2011-2012 Artem Los, www.clizware.net. //The author of this code shall get the credits @@ -13,581 +12,11 @@ // A great thank to Iberna (https://www.codeplex.com/site/users/view/lberna) // for getHardDiskSerial algorithm. -using System.Text; -using System.Management; -using System.Security; -using System.Numerics; -using System.Net.NetworkInformation; -using System.Linq; - - [assembly: AllowPartiallyTrustedCallers()] namespace SKGL { -#region "S E R I A L K E Y G E N E R A T I N G L I B R A R Y" - -#region "CONFIGURATION" - - public abstract class BaseConfiguration - { - //Put all functions/variables that should be shared with - //all other classes that inherit this class. - // - //note, this class cannot be used as a normal class that - //you define because it is MustInherit. - - protected internal string _key = ""; - /// - /// The key will be stored here - /// - public virtual string Key - { - //will be changed in both generating and validating classe. - get { return _key; } - set { _key = value; } - } - - /// - /// - /// - /// - /// - /// - public virtual int MachineCode - { - - get { return getMachineCode(); } - } - - [SecuritySafeCritical] - private static int getMachineCode() - { - // please see https://skgl.codeplex.com/workitem/2246 for a list of developers of this code. - - methods m = new methods(); - - ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_Processor"); - string collectedInfo = ""; - // here we will put the informa - foreach (ManagementObject share in searcher.Get()) - { - // first of all, the processorid - collectedInfo += share.GetPropertyValue("ProcessorId"); - } - - searcher.Query = new ObjectQuery("select * from Win32_BIOS"); - foreach (ManagementObject share in searcher.Get()) - { - //then, the serial number of BIOS - collectedInfo += share.GetPropertyValue("SerialNumber"); - } - - searcher.Query = new ObjectQuery("select * from Win32_BaseBoard"); - foreach (ManagementObject share in searcher.Get()) - { - //finally, the serial number of motherboard - collectedInfo += share.GetPropertyValue("SerialNumber"); - } - - // patch luca bernardini - if (string.IsNullOrEmpty(collectedInfo) | collectedInfo == "00" | collectedInfo.Length <= 3) - { - collectedInfo += getHddSerialNumber(); - } - - // In case we have message "To be filled by O.E.M." - there is incorrect motherboard/BIOS serial number - // - we should relay to NIC - if (collectedInfo.Contains("To be filled by O.E.M.")) - { - var nic = GetNicInfo(); - - if (!string.IsNullOrWhiteSpace(nic)) - collectedInfo += nic; - } - - return m.getEightByteHash(collectedInfo, 100000); - - } - - /// - /// Enumerate all Nic adapters, take first one, who has MAC address and return it. - /// - /// Function MUST! be updated to select only real NIC cards (and filter out USB and PPTP etc interfaces). - /// Otherwise user can run in this scenario: a) Insert USB NIC b) Generate machine code c) Remove USB NIC... - /// - /// MAC address of NIC adapter - [SecuritySafeCritical] - private static string GetNicInfo() - { - var nics = NetworkInterface.GetAllNetworkInterfaces(); - var mac = string.Empty; - - foreach (var adapter in nics.Where(adapter => string.IsNullOrWhiteSpace(mac))) - mac = adapter.GetPhysicalAddress().ToString(); - - return mac; - } - - /// - /// Read the serial number from the hard disk that keep the bootable partition (boot disk) - /// - /// - /// If succedes, returns the string rappresenting the Serial Number. - /// String.Empty if it fails. - /// - [SecuritySafeCritical] - private static string getHddSerialNumber() - { - // --- Win32 Disk - ManagementObjectSearcher searcher = new ManagementObjectSearcher("\\root\\cimv2", "select * from Win32_DiskPartition WHERE BootPartition=True"); - - uint diskIndex = 999; - foreach (ManagementObject partition in searcher.Get()) - { - diskIndex = Convert.ToUInt32(partition.GetPropertyValue("DiskIndex")); // should be DiskIndex - break; // TODO: might not be correct. Was : Exit For - } - - // I haven't found the bootable partition. Fail. - if (diskIndex == 999) - return string.Empty; - - - - // --- Win32 Disk Drive - searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive where Index = " + diskIndex.ToString()); - - string deviceName = ""; - foreach (ManagementObject wmi_HD in searcher.Get()) - { - deviceName = wmi_HD.GetPropertyValue("Name").ToString(); - break; // TODO: might not be correct. Was : Exit For - } - - - // I haven't found the disk drive. Fail - if (string.IsNullOrEmpty(deviceName.Trim())) - return string.Empty; - - // -- Some problems in query parsing with backslash. Using like operator - if (deviceName.StartsWith("\\\\.\\")) - { - deviceName = deviceName.Replace("\\\\.\\", "%"); - } - - - // --- Physical Media - searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia WHERE Tag like '" + deviceName + "'"); - string serial = string.Empty; - foreach (ManagementObject wmi_HD in searcher.Get()) - { - serial = wmi_HD.GetPropertyValue("SerialNumber").ToString(); - break; // TODO: might not be correct. Was : Exit For - } - - return serial; - - } - - } - public class SerialKeyConfiguration : BaseConfiguration - { - - #region "V A R I A B L E S" - private bool[] _Features = new bool[8] { - false, - false, - false, - false, - false, - false, - false, - false - //the default value of the Fetures array. - }; - public virtual bool[] Features - { - //will be changed in validating class. - get { return _Features; } - set { _Features = value; } - } - private bool _addSplitChar = true; - public bool addSplitChar - { - get { return _addSplitChar; } - set { _addSplitChar = value; } - } - - - #endregion - - } -#endregion - - #region "ENCRYPTION" - public class Generate : BaseConfiguration - { - //this class have to be inherited because of the key which is shared with both encryption/decryption classes. - - SerialKeyConfiguration skc = new SerialKeyConfiguration(); - methods m = new methods(); - Random r = new Random(); - public Generate() - { - // No overloads works with Sub New - } - public Generate(SerialKeyConfiguration _serialKeyConfiguration) - { - skc = _serialKeyConfiguration; - } - - private string _secretPhase; - /// - /// If the key is to be encrypted, enter a password here. - /// - - public string secretPhase - { - get { return _secretPhase; } - set - { - if (value != _secretPhase) - { - _secretPhase = m.twentyfiveByteHash(value); - } - } - } - /// - /// This function will generate a key. - /// - /// For instance, 30 days. - public string doKey(int timeLeft) - { - return doKey(timeLeft, DateTime.Today); // removed extra argument false - } - - /// - /// - /// - /// For instance, 30 days - /// Lock a serial key to a specific machine, given its "machine code". Should be 5 digits long. - /// - /// - public object doKey(int timeLeft, int useMachineCode) - { - return doKey(timeLeft, DateTime.Today, useMachineCode); - } - - /// - /// This function will generate a key. You may also change the creation date. - /// - /// For instance, 30 days. - /// Change the creation date of a key. - /// Lock a serial key to a specific machine, given its "machine code". Should be 5 digits long. - public string doKey(int timeLeft, System.DateTime creationDate, int useMachineCode = 0) - { - if (timeLeft > 999) - { - //Checking if the timeleft is NOT larger than 999. It cannot be larger to match the key-length 20. - throw new ArgumentException("The timeLeft is larger than 999. It can only consist of three digits."); - } - - if (!string.IsNullOrEmpty(secretPhase) | secretPhase != null) - { - //if some kind of value is assigned to the variable "secretPhase", the code will execute it FIRST. - //the secretPhase shall only consist of digits! - System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("^\\d$"); - //cheking the string - if (reg.IsMatch(secretPhase)) - { - //throwing new exception if the string contains non-numrical letters. - throw new ArgumentException("The secretPhase consist of non-numerical letters."); - } - } - - //if no exception is thown, do following - string _stageThree = null; - if (useMachineCode > 0 & useMachineCode <= 99999) - { - _stageThree = m._encrypt(timeLeft, skc.Features, secretPhase, useMachineCode, creationDate); - // stage one - } - else - { - _stageThree = m._encrypt(timeLeft, skc.Features, secretPhase, r.Next(0, 99999), creationDate); - // stage one - } - - //if it is the same value as default, we do not need to mix chars. This step saves generation time. - - if (skc.addSplitChar == true) - { - // by default, a split character will be addedr - Key = _stageThree.Substring(0, 5) + "-" + _stageThree.Substring(5, 5) + "-" + _stageThree.Substring(10, 5) + "-" + _stageThree.Substring(15, 5); - } - else - { - Key = _stageThree; - } - - //we also include the key in the Key variable to make it possible for user to get his key without generating a new one. - return Key; - - } - - - } - #endregion - - #region "DECRYPTION" - public class Validate : BaseConfiguration - { - //this class have to be inherited becuase of the key which is shared with both encryption/decryption classes. - - SerialKeyConfiguration skc = new SerialKeyConfiguration(); - methods _a = new methods(); - public Validate() - { - // No overloads works with Sub New - } - public Validate(SerialKeyConfiguration _serialKeyConfiguration) - { - skc = _serialKeyConfiguration; - } - /// - /// Enter a key here before validating. - /// - public string Key - { - //re-defining the Key - get { return _key; } - set - { - _res = ""; - _key = value; - } - } - - private string _secretPhase = ""; - /// - /// If the key has been encrypted, when it was generated, please set the same secretPhase here. - /// - public string secretPhase - { - get { return _secretPhase; } - set - { - if (value != _secretPhase) - { - _secretPhase = _a.twentyfiveByteHash(value); - } - } - } - - - private string _res = ""; - - private void decodeKeyToString() - { - // checking if the key already have been decoded. - if (string.IsNullOrEmpty(_res) | _res == null) - { - - string _stageOne = ""; - - Key = Key.Replace("-", ""); - - //if the admBlock has been changed, the getMixChars will be executed. - - - _stageOne = Key; - - - _stageOne = Key; - - // _stageTwo = _a._decode(_stageOne) - - if (!string.IsNullOrEmpty(secretPhase) | secretPhase != null) - { - //if no value "secretPhase" given, the code will directly decrypt without using somekind of encryption - //if some kind of value is assigned to the variable "secretPhase", the code will execute it FIRST. - //the secretPhase shall only consist of digits! - System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("^\\d$"); - //cheking the string - if (reg.IsMatch(secretPhase)) - { - //throwing new exception if the string contains non-numrical letters. - throw new ArgumentException("The secretPhase consist of non-numerical letters."); - } - } - _res = _a._decrypt(_stageOne, secretPhase); - - - } - } - private bool _IsValid() - { - //Dim _a As New methods ' is only here to provide the geteighthashcode method - try - { - if (Key.Contains("-")) - { - if (Key.Length != 23) - { - return false; - } - } - else - { - if (Key.Length != 20) - { - return false; - } - } - decodeKeyToString(); - - string _decodedHash = _res.Substring(0, 9); - string _calculatedHash = _a.getEightByteHash(_res.Substring(9, 19)).ToString().Substring(0, 9); - // changed Math.Abs(_res.Substring(0, 17).GetHashCode).ToString.Substring(0, 8) - - //When the hashcode is calculated, it cannot be taken for sure, - //that the same hash value will be generated. - //learn more about this issue: http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx - if (_decodedHash == _calculatedHash) - { - return true; - } - else - { - return false; - } - } - catch (Exception ex) - { - //if something goes wrong, for example, when decrypting, - //this function will return false, so that user knows that it is unvalid. - //if the key is valid, there won't be any errors. - return false; - } - } - /// - /// Checks whether the key has been modified or not. If the key has been modified - returns false; if the key has not been modified - returns true. - /// - public bool IsValid - { - get { return _IsValid(); } - } - private bool _IsExpired() - { - if (DaysLeft > 0) - { - return false; - } - else - { - return true; - } - } - /// - /// If the key has expired - returns true; if the key has not expired - returns false. - /// - public bool IsExpired - { - get { return _IsExpired(); } - } - private System.DateTime _CreationDay() - { - decodeKeyToString(); - System.DateTime _date = new System.DateTime(); - _date = new DateTime(Convert.ToInt32(_res.Substring(9, 4)), Convert.ToInt32(_res.Substring(13, 2)), Convert.ToInt32(_res.Substring(15, 2))); - - return _date; - } - /// - /// Returns the creation date of the key. - /// - public System.DateTime CreationDate - { - get { return _CreationDay(); } - } - private int _DaysLeft() - { - decodeKeyToString(); - int _setDays = SetTime; - return Convert.ToInt32(((TimeSpan)(ExpireDate - DateTime.Today)).TotalDays); //or viseversa - } - /// - /// Returns the amount of days the key will be valid. - /// - public int DaysLeft - { - get { return _DaysLeft(); } - } - - private int _SetTime() - { - decodeKeyToString(); - return Convert.ToInt32(_res.Substring(17, 3)); - } - /// - /// Returns the actual amount of days that were set when the key was generated. - /// - public int SetTime - { - get { return _SetTime(); } - } - private System.DateTime _ExpireDate() - { - decodeKeyToString(); - System.DateTime _date = new System.DateTime(); - _date = CreationDate; - return _date.AddDays(SetTime); - } - /// - /// Returns the date when the key is to be expired. - /// - public System.DateTime ExpireDate - { - get { return _ExpireDate(); } - } - private bool[] _Features() - { - decodeKeyToString(); - return _a.intToBoolean(Convert.ToInt32(_res.Substring(20, 3))); - } - /// - /// Returns all 8 features in a boolean array - /// - public bool[] Features - { - //we already have defined Features in the BaseConfiguration class. - //Here we only change it to Read Only. - get { return _Features(); } - } - - /// - /// If the current machine's machine code is equal to the one that this key is designed for, return true. - /// - /// - /// - /// - public bool IsOnRightMachine - { - get - { - int decodedMachineCode = Convert.ToInt32(_res.Substring(23, 5)); - - return decodedMachineCode == MachineCode; - } - } - } - #endregion - - #region "T H E C O R E O F S K G L" - internal class methods : SerialKeyConfiguration { - //The construction of the key protected internal string _encrypt(int _days, bool[] _tfg, string _secretPhase, int ID, System.DateTime _creationDate) { @@ -622,16 +51,15 @@ protected internal string _encrypt(int _days, bool[] _tfg, string _secretPhase, if (string.IsNullOrEmpty(_secretPhase) | _secretPhase == null) { // if not password is set, return an unencrypted key - return base10ToBase26((getEightByteHash(result.ToString()) +result.ToString())); + return base10ToBase26((getEightByteHash(result.ToString()) + result.ToString())); } else { // if password is set, return an encrypted - return base10ToBase26((getEightByteHash(result.ToString()) + _encText(result.ToString(), _secretPhase) )); + return base10ToBase26((getEightByteHash(result.ToString()) + _encText(result.ToString(), _secretPhase))); } - - } + protected internal string _decrypt(string _key, string _secretPhase) { if (string.IsNullOrEmpty(_secretPhase) | _secretPhase == null) @@ -670,6 +98,7 @@ protected internal int booleanToInt(bool[] _booleanArray) } return _aVector; } + protected internal bool[] intToBoolean(int _num) { //In this function we are converting an integer (created with privious function) to a binary array @@ -685,6 +114,7 @@ protected internal bool[] intToBoolean(int _num) } return _cReturn; } + protected internal string _encText(string _inputPhase, string _secretPhase) { //in this class we are encrypting the integer array. @@ -697,6 +127,7 @@ protected internal string _encText(string _inputPhase, string _secretPhase) return _res; } + protected internal string _decText(string _encryptedPhase, string _secretPhase) { //in this class we are decrypting the text encrypted with the function above. @@ -709,6 +140,7 @@ protected internal string _decText(string _encryptedPhase, string _secretPhase) return _res; } + protected internal string Return_Lenght(string Number, int Lenght) { // This function create 3 lenght char ex: 39 to 039 @@ -723,6 +155,7 @@ protected internal string Return_Lenght(string Number, int Lenght) //Return Number } + protected internal int modulo(int _num, int _base) { // canged return type to integer. @@ -731,6 +164,7 @@ protected internal int modulo(int _num, int _base) //number in the result! return _num - _base * Convert.ToInt32(Math.Floor((decimal)_num / (decimal)_base)); } + protected internal string twentyfiveByteHash(string s) { int amountOfBlocks = s.Length / 5; @@ -753,6 +187,7 @@ protected internal string twentyfiveByteHash(string s) } return string.Join("", preHash); } + protected internal int getEightByteHash(string s, int MUST_BE_LESS_THAN = 1000000000) { //This function generates a eight byte hash @@ -795,6 +230,7 @@ protected internal int getEightByteHash(string s, int MUST_BE_LESS_THAN = 100000 return result; } + protected internal string base10ToBase26(string s) { // This method is converting a base 10 number to base 26 number. @@ -832,6 +268,7 @@ protected internal string base10ToBase26(string s) return returnNum; } + protected internal string base26ToBase10(string s) { // This function will convert a number that has been generated @@ -862,30 +299,20 @@ protected internal BigInteger powof(int x, int y) BigInteger newNum = 1; if (y == 0) - { return 1; - // if 0, return 1, e.g. x^0 = 1 (mathematicaly proven!) - } - else if (y == 1) - { + // if 0, return 1, e.g. x^0 = 1 (mathematicaly proven!) + + if (y == 1) return x; - // if 1, return x, which is the base, e.g. x^1 = x - } - else + // if 1, return x, which is the base, e.g. x^1 = x + + for (int i = 0; i <= y - 1; i++) { - for (int i = 0; i <= y - 1; i++) - { - newNum = newNum * x; - } - return newNum; - // if both conditions are not satisfied, this loop - // will continue to y, which is the exponent. + newNum = newNum * x; } + return newNum; + // if both conditions are not satisfied, this loop + // will continue to y, which is the exponent. } } - - - #endregion - -#endregion } \ No newline at end of file diff --git a/SKGL 2.0.5.2/SKGL.csproj b/SKGL 2.0.5.2/SKGL.csproj index 2fdcf66..3937156 100644 --- a/SKGL 2.0.5.2/SKGL.csproj +++ b/SKGL 2.0.5.2/SKGL.csproj @@ -34,10 +34,10 @@ 4 - true + false - certificate.pfx + certificate.pdf.snk @@ -51,10 +51,15 @@ + + + + + diff --git a/SKGL 2.0.5.2/SerialKeyConfiguration.cs b/SKGL 2.0.5.2/SerialKeyConfiguration.cs new file mode 100644 index 0000000..dfdce1b --- /dev/null +++ b/SKGL 2.0.5.2/SerialKeyConfiguration.cs @@ -0,0 +1,29 @@ +using SKGL.Base; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SKGL +{ + public class SerialKeyConfiguration : BaseConfiguration + { + private bool[] _Features = new bool[8]; //when define an array with no initial value, .Net Framework will set primitive array values as false + + public virtual bool[] Features + { + //will be changed in validating class. + get { return _Features; } + set { _Features = value; } + } + + private bool _addSplitChar = true; + public bool addSplitChar + { + get { return _addSplitChar; } + set { _addSplitChar = value; } + } + + + } +} diff --git a/SKGL 2.0.5.2/Validate.cs b/SKGL 2.0.5.2/Validate.cs new file mode 100644 index 0000000..b6854f4 --- /dev/null +++ b/SKGL 2.0.5.2/Validate.cs @@ -0,0 +1,252 @@ +using SKGL.Base; +using System; + +namespace SKGL +{ + public class Validate : BaseConfiguration + { + //this class have to be inherited becuase of the key which is shared with both encryption/decryption classes. + + SerialKeyConfiguration skc = new SerialKeyConfiguration(); + methods _a = new methods(); + public Validate() + { + // No overloads works with Sub New + } + + public Validate(SerialKeyConfiguration _serialKeyConfiguration) + { + skc = _serialKeyConfiguration; + } + + /// + /// Enter a key here before validating. + /// + public string Key + { + //re-defining the Key + get { return _key; } + set + { + _res = ""; + _key = value; + } + } + + private string _secretPhase = ""; + /// + /// If the key has been encrypted, when it was generated, please set the same secretPhase here. + /// + public string secretPhase + { + get { return _secretPhase; } + set + { + if (value != _secretPhase) + { + _secretPhase = _a.twentyfiveByteHash(value); + } + } + } + + + private string _res = ""; + + private void decodeKeyToString() + { + // checking if the key already have been decoded. + if (string.IsNullOrEmpty(_res) | _res == null) + { + + string _stageOne = ""; + + Key = Key.Replace("-", ""); + + //if the admBlock has been changed, the getMixChars will be executed. + + + _stageOne = Key; + + + _stageOne = Key; + + // _stageTwo = _a._decode(_stageOne) + + if (!string.IsNullOrEmpty(secretPhase) | secretPhase != null) + { + //if no value "secretPhase" given, the code will directly decrypt without using somekind of encryption + //if some kind of value is assigned to the variable "secretPhase", the code will execute it FIRST. + //the secretPhase shall only consist of digits! + System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("^\\d$"); + //cheking the string + if (reg.IsMatch(secretPhase)) + { + //throwing new exception if the string contains non-numrical letters. + throw new ArgumentException("The secretPhase consist of non-numerical letters."); + } + } + _res = _a._decrypt(_stageOne, secretPhase); + + + } + } + private bool _IsValid() + { + //Dim _a As New methods ' is only here to provide the geteighthashcode method + try + { + if (Key.Contains("-")) + { + if (Key.Length != 23) + { + return false; + } + } + else + { + if (Key.Length != 20) + { + return false; + } + } + decodeKeyToString(); + + string _decodedHash = _res.Substring(0, 9); + string _calculatedHash = _a.getEightByteHash(_res.Substring(9, 19)).ToString().Substring(0, 9); + // changed Math.Abs(_res.Substring(0, 17).GetHashCode).ToString.Substring(0, 8) + + //When the hashcode is calculated, it cannot be taken for sure, + //that the same hash value will be generated. + //learn more about this issue: http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx + if (_decodedHash == _calculatedHash) + { + return true; + } + else + { + return false; + } + } + catch (Exception ex) + { + //if something goes wrong, for example, when decrypting, + //this function will return false, so that user knows that it is unvalid. + //if the key is valid, there won't be any errors. + return false; + } + } + + /// + /// Checks whether the key has been modified or not. If the key has been modified - returns false; if the key has not been modified - returns true. + /// + public bool IsValid + { + get { return _IsValid(); } + } + private bool _IsExpired() + { + if (DaysLeft > 0) + { + return false; + } + else + { + return true; + } + } + /// + /// If the key has expired - returns true; if the key has not expired - returns false. + /// + public bool IsExpired + { + get { return _IsExpired(); } + } + private System.DateTime _CreationDay() + { + decodeKeyToString(); + System.DateTime _date = new System.DateTime(); + _date = new DateTime(Convert.ToInt32(_res.Substring(9, 4)), Convert.ToInt32(_res.Substring(13, 2)), Convert.ToInt32(_res.Substring(15, 2))); + + return _date; + } + /// + /// Returns the creation date of the key. + /// + public System.DateTime CreationDate + { + get { return _CreationDay(); } + } + private int _DaysLeft() + { + decodeKeyToString(); + int _setDays = SetTime; + return Convert.ToInt32(((TimeSpan)(ExpireDate - DateTime.Today)).TotalDays); //or viseversa + } + /// + /// Returns the amount of days the key will be valid. + /// + public int DaysLeft + { + get { return _DaysLeft(); } + } + + private int _SetTime() + { + decodeKeyToString(); + return Convert.ToInt32(_res.Substring(17, 3)); + } + + /// + /// Returns the actual amount of days that were set when the key was generated. + /// + public int SetTime + { + get { return _SetTime(); } + } + + private System.DateTime _ExpireDate() + { + decodeKeyToString(); + System.DateTime _date = new System.DateTime(); + _date = CreationDate; + return _date.AddDays(SetTime); + } + /// + /// Returns the date when the key is to be expired. + /// + public System.DateTime ExpireDate + { + get { return _ExpireDate(); } + } + private bool[] _Features() + { + decodeKeyToString(); + return _a.intToBoolean(Convert.ToInt32(_res.Substring(20, 3))); + } + /// + /// Returns all 8 features in a boolean array + /// + public bool[] Features + { + //we already have defined Features in the BaseConfiguration class. + //Here we only change it to Read Only. + get { return _Features(); } + } + + /// + /// If the current machine's machine code is equal to the one that this key is designed for, return true. + /// + /// + /// + /// + public bool IsOnRightMachine + { + get + { + int decodedMachineCode = Convert.ToInt32(_res.Substring(23, 5)); + + return decodedMachineCode == MachineCode; + } + } + } +} diff --git a/SKGL 2.0.5.2/bin/Debug/SKGL.dll b/SKGL 2.0.5.2/bin/Debug/SKGL.dll deleted file mode 100644 index 6d313ab..0000000 Binary files a/SKGL 2.0.5.2/bin/Debug/SKGL.dll and /dev/null differ diff --git a/SKGL 2.0.5.2/bin/Debug/SKGL.pdb b/SKGL 2.0.5.2/bin/Debug/SKGL.pdb deleted file mode 100644 index 71bf6f7..0000000 Binary files a/SKGL 2.0.5.2/bin/Debug/SKGL.pdb and /dev/null differ diff --git a/SKGL 2.0.5.2/certificate.pdf.snk b/SKGL 2.0.5.2/certificate.pdf.snk new file mode 100644 index 0000000..efa8985 Binary files /dev/null and b/SKGL 2.0.5.2/certificate.pdf.snk differ diff --git a/SKGL 2.0.5.2/certificate.pfx b/SKGL 2.0.5.2/certificate.pfx deleted file mode 100644 index 56073ca..0000000 Binary files a/SKGL 2.0.5.2/certificate.pfx and /dev/null differ diff --git a/SKGL 2.0.5.2/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/SKGL 2.0.5.2/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache deleted file mode 100644 index ad03368..0000000 Binary files a/SKGL 2.0.5.2/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and /dev/null differ diff --git a/SKGL 2.0.5.2/obj/Debug/SKGL.csproj.FileListAbsolute.txt b/SKGL 2.0.5.2/obj/Debug/SKGL.csproj.FileListAbsolute.txt deleted file mode 100644 index a4f22a1..0000000 --- a/SKGL 2.0.5.2/obj/Debug/SKGL.csproj.FileListAbsolute.txt +++ /dev/null @@ -1,5 +0,0 @@ -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGL 2.0.5.2\bin\Debug\SKGL.dll -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGL 2.0.5.2\bin\Debug\SKGL.pdb -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGL 2.0.5.2\obj\Debug\SKGL.csprojResolveAssemblyReference.cache -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGL 2.0.5.2\obj\Debug\SKGL.dll -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGL 2.0.5.2\obj\Debug\SKGL.pdb diff --git a/SKGL 2.0.5.2/obj/Debug/SKGL.csprojResolveAssemblyReference.cache b/SKGL 2.0.5.2/obj/Debug/SKGL.csprojResolveAssemblyReference.cache deleted file mode 100644 index ec582d2..0000000 Binary files a/SKGL 2.0.5.2/obj/Debug/SKGL.csprojResolveAssemblyReference.cache and /dev/null differ diff --git a/SKGL 2.0.5.2/obj/Debug/SKGL.dll b/SKGL 2.0.5.2/obj/Debug/SKGL.dll deleted file mode 100644 index 6d313ab..0000000 Binary files a/SKGL 2.0.5.2/obj/Debug/SKGL.dll and /dev/null differ diff --git a/SKGL 2.0.5.2/obj/Debug/SKGL.pdb b/SKGL 2.0.5.2/obj/Debug/SKGL.pdb deleted file mode 100644 index 71bf6f7..0000000 Binary files a/SKGL 2.0.5.2/obj/Debug/SKGL.pdb and /dev/null differ diff --git a/SKGL Plus/SKGL Plus.csproj.vspscc b/SKGL Plus/SKGL Plus.csproj.vspscc deleted file mode 100644 index b6d3289..0000000 --- a/SKGL Plus/SKGL Plus.csproj.vspscc +++ /dev/null @@ -1,10 +0,0 @@ -"" -{ -"FILE_VERSION" = "9237" -"ENLISTMENT_CHOICE" = "NEVER" -"PROJECT_FILE_RELATIVE_PATH" = "" -"NUMBER_OF_EXCLUDED_FILES" = "0" -"ORIGINAL_PROJECT_FILE_PATH" = "" -"NUMBER_OF_NESTED_PROJECTS" = "0" -"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" -} diff --git a/SKGL Plus/bin/Debug/SKGL Plus.dll b/SKGL Plus/bin/Debug/SKGL Plus.dll deleted file mode 100644 index 2d3a0e1..0000000 Binary files a/SKGL Plus/bin/Debug/SKGL Plus.dll and /dev/null differ diff --git a/SKGL Plus/bin/Debug/SKGL Plus.pdb b/SKGL Plus/bin/Debug/SKGL Plus.pdb deleted file mode 100644 index 2849563..0000000 Binary files a/SKGL Plus/bin/Debug/SKGL Plus.pdb and /dev/null differ diff --git a/SKGL Plus/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/SKGL Plus/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache deleted file mode 100644 index ad3a034..0000000 Binary files a/SKGL Plus/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and /dev/null differ diff --git a/SKGL Plus/obj/Debug/SKGL Plus.csproj.FileListAbsolute.txt b/SKGL Plus/obj/Debug/SKGL Plus.csproj.FileListAbsolute.txt deleted file mode 100644 index 6805ed0..0000000 --- a/SKGL Plus/obj/Debug/SKGL Plus.csproj.FileListAbsolute.txt +++ /dev/null @@ -1,5 +0,0 @@ -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGL Plus\bin\Debug\SKGL Plus.dll -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGL Plus\bin\Debug\SKGL Plus.pdb -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGL Plus\obj\Debug\SKGL Plus.csprojResolveAssemblyReference.cache -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGL Plus\obj\Debug\SKGL Plus.dll -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGL Plus\obj\Debug\SKGL Plus.pdb diff --git a/SKGL Plus/obj/Debug/SKGL Plus.csprojResolveAssemblyReference.cache b/SKGL Plus/obj/Debug/SKGL Plus.csprojResolveAssemblyReference.cache deleted file mode 100644 index ec582d2..0000000 Binary files a/SKGL Plus/obj/Debug/SKGL Plus.csprojResolveAssemblyReference.cache and /dev/null differ diff --git a/SKGL Plus/obj/Debug/SKGL Plus.dll b/SKGL Plus/obj/Debug/SKGL Plus.dll deleted file mode 100644 index 2d3a0e1..0000000 Binary files a/SKGL Plus/obj/Debug/SKGL Plus.dll and /dev/null differ diff --git a/SKGL Plus/obj/Debug/SKGL Plus.pdb b/SKGL Plus/obj/Debug/SKGL Plus.pdb deleted file mode 100644 index 2849563..0000000 Binary files a/SKGL Plus/obj/Debug/SKGL Plus.pdb and /dev/null differ diff --git a/SKGL.v12.suo b/SKGL.v12.suo deleted file mode 100644 index 6cad2b0..0000000 Binary files a/SKGL.v12.suo and /dev/null differ diff --git a/SKGLTest/SKGLTest.csproj.vspscc b/SKGLTest/SKGLTest.csproj.vspscc deleted file mode 100644 index b6d3289..0000000 --- a/SKGLTest/SKGLTest.csproj.vspscc +++ /dev/null @@ -1,10 +0,0 @@ -"" -{ -"FILE_VERSION" = "9237" -"ENLISTMENT_CHOICE" = "NEVER" -"PROJECT_FILE_RELATIVE_PATH" = "" -"NUMBER_OF_EXCLUDED_FILES" = "0" -"ORIGINAL_PROJECT_FILE_PATH" = "" -"NUMBER_OF_NESTED_PROJECTS" = "0" -"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" -} diff --git a/SKGLTest/UnitTest1.cs b/SKGLTest/UnitTest1.cs index 59af752..2693ccf 100644 --- a/SKGLTest/UnitTest1.cs +++ b/SKGLTest/UnitTest1.cs @@ -10,24 +10,61 @@ public class UnitTest1 public void MachineCodeTest() { SKGL.Generate gen = new SKGL.Generate(); - string a= gen.MachineCode.ToString(); + string a = gen.MachineCode.ToString(); } [TestMethod] public void CreateAndValidateSimple() { SKGL.Generate gen = new SKGL.Generate(); - string a = gen.doKey(30); + string a = gen.doKey(30); SKGL.Validate val = new SKGL.Validate(); val.Key = a; - + Assert.IsTrue(val.IsValid == true); - Assert.IsTrue(val.IsExpired ==false); + Assert.IsTrue(val.IsExpired == false); Assert.IsTrue(val.SetTime == 30); } + + [TestMethod] + public void CreateAndValidate999Days() + { + SKGL.Generate gen = new SKGL.Generate(); + string a = gen.doKey(999); + + SKGL.Validate val = new SKGL.Validate(); + + val.Key = a; + + Assert.IsTrue(val.IsValid == true); + Assert.IsTrue(val.IsExpired == false); + + + } + + + [TestMethod] + public void CreateAndValidate999DaysWithSecretPhase() + { + SKGL.Generate gen = new SKGL.Generate(); + + gen.secretPhase = "d87e468e-02ae-4112-a687-fb4a402a2f7a"; + + string a = gen.doKey(999); + + SKGL.Validate val = new SKGL.Validate(); + val.secretPhase = "d87e468e-02ae-4112-a687-fb4a402a2f7a"; + val.Key = a; + + Assert.IsTrue(val.IsValid == true); + Assert.IsTrue(val.IsExpired == false); + + + } + [TestMethod] public void CreateAndValidateA() { diff --git a/SKGLTest/bin/Debug/SKGL Plus.dll b/SKGLTest/bin/Debug/SKGL Plus.dll deleted file mode 100644 index 2d3a0e1..0000000 Binary files a/SKGLTest/bin/Debug/SKGL Plus.dll and /dev/null differ diff --git a/SKGLTest/bin/Debug/SKGL Plus.pdb b/SKGLTest/bin/Debug/SKGL Plus.pdb deleted file mode 100644 index 2849563..0000000 Binary files a/SKGLTest/bin/Debug/SKGL Plus.pdb and /dev/null differ diff --git a/SKGLTest/bin/Debug/SKGL.dll b/SKGLTest/bin/Debug/SKGL.dll deleted file mode 100644 index 6d313ab..0000000 Binary files a/SKGLTest/bin/Debug/SKGL.dll and /dev/null differ diff --git a/SKGLTest/bin/Debug/SKGL.pdb b/SKGLTest/bin/Debug/SKGL.pdb deleted file mode 100644 index 71bf6f7..0000000 Binary files a/SKGLTest/bin/Debug/SKGL.pdb and /dev/null differ diff --git a/SKGLTest/bin/Debug/SKGLTest.dll b/SKGLTest/bin/Debug/SKGLTest.dll deleted file mode 100644 index a08737a..0000000 Binary files a/SKGLTest/bin/Debug/SKGLTest.dll and /dev/null differ diff --git a/SKGLTest/bin/Debug/SKGLTest.pdb b/SKGLTest/bin/Debug/SKGLTest.pdb deleted file mode 100644 index c24138c..0000000 Binary files a/SKGLTest/bin/Debug/SKGLTest.pdb and /dev/null differ diff --git a/SKGLTest/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/SKGLTest/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache deleted file mode 100644 index efb11a1..0000000 Binary files a/SKGLTest/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and /dev/null differ diff --git a/SKGLTest/obj/Debug/SKGLTest.csproj.FileListAbsolute.txt b/SKGLTest/obj/Debug/SKGLTest.csproj.FileListAbsolute.txt deleted file mode 100644 index 7c86e1d..0000000 --- a/SKGLTest/obj/Debug/SKGLTest.csproj.FileListAbsolute.txt +++ /dev/null @@ -1,9 +0,0 @@ -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGLTest\bin\Debug\SKGLTest.dll -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGLTest\bin\Debug\SKGLTest.pdb -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGLTest\bin\Debug\SKGL Plus.dll -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGLTest\bin\Debug\SKGL.dll -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGLTest\bin\Debug\SKGL.pdb -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGLTest\bin\Debug\SKGL Plus.pdb -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGLTest\obj\Debug\SKGLTest.csprojResolveAssemblyReference.cache -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGLTest\obj\Debug\SKGLTest.dll -C:\Users\Artem Los\Documents\GitHub\SKGL\SKGLTest\obj\Debug\SKGLTest.pdb diff --git a/SKGLTest/obj/Debug/SKGLTest.csprojResolveAssemblyReference.cache b/SKGLTest/obj/Debug/SKGLTest.csprojResolveAssemblyReference.cache deleted file mode 100644 index 4dc75cb..0000000 Binary files a/SKGLTest/obj/Debug/SKGLTest.csprojResolveAssemblyReference.cache and /dev/null differ diff --git a/SKGLTest/obj/Debug/SKGLTest.dll b/SKGLTest/obj/Debug/SKGLTest.dll deleted file mode 100644 index a08737a..0000000 Binary files a/SKGLTest/obj/Debug/SKGLTest.dll and /dev/null differ diff --git a/SKGLTest/obj/Debug/SKGLTest.pdb b/SKGLTest/obj/Debug/SKGLTest.pdb deleted file mode 100644 index c24138c..0000000 Binary files a/SKGLTest/obj/Debug/SKGLTest.pdb and /dev/null differ diff --git a/SpeedComparsison/SpeedComparsison.csproj.vspscc b/SpeedComparsison/SpeedComparsison.csproj.vspscc deleted file mode 100644 index b6d3289..0000000 --- a/SpeedComparsison/SpeedComparsison.csproj.vspscc +++ /dev/null @@ -1,10 +0,0 @@ -"" -{ -"FILE_VERSION" = "9237" -"ENLISTMENT_CHOICE" = "NEVER" -"PROJECT_FILE_RELATIVE_PATH" = "" -"NUMBER_OF_EXCLUDED_FILES" = "0" -"ORIGINAL_PROJECT_FILE_PATH" = "" -"NUMBER_OF_NESTED_PROJECTS" = "0" -"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" -} diff --git a/SpeedComparsison/bin/Debug/SKGL.dll b/SpeedComparsison/bin/Debug/SKGL.dll deleted file mode 100644 index 6d313ab..0000000 Binary files a/SpeedComparsison/bin/Debug/SKGL.dll and /dev/null differ diff --git a/SpeedComparsison/bin/Debug/SKGL.pdb b/SpeedComparsison/bin/Debug/SKGL.pdb deleted file mode 100644 index 71bf6f7..0000000 Binary files a/SpeedComparsison/bin/Debug/SKGL.pdb and /dev/null differ diff --git a/SpeedComparsison/bin/Debug/SpeedComparsison.dll b/SpeedComparsison/bin/Debug/SpeedComparsison.dll deleted file mode 100644 index 1bc97dc..0000000 Binary files a/SpeedComparsison/bin/Debug/SpeedComparsison.dll and /dev/null differ diff --git a/SpeedComparsison/bin/Debug/SpeedComparsison.pdb b/SpeedComparsison/bin/Debug/SpeedComparsison.pdb deleted file mode 100644 index bb73e3c..0000000 Binary files a/SpeedComparsison/bin/Debug/SpeedComparsison.pdb and /dev/null differ diff --git a/SpeedComparsison/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/SpeedComparsison/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache deleted file mode 100644 index a898bdc..0000000 Binary files a/SpeedComparsison/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and /dev/null differ diff --git a/SpeedComparsison/obj/Debug/SpeedComparsison.csproj.FileListAbsolute.txt b/SpeedComparsison/obj/Debug/SpeedComparsison.csproj.FileListAbsolute.txt deleted file mode 100644 index 0e3185f..0000000 --- a/SpeedComparsison/obj/Debug/SpeedComparsison.csproj.FileListAbsolute.txt +++ /dev/null @@ -1,7 +0,0 @@ -C:\Users\Artem Los\Documents\GitHub\SKGL\SpeedComparsison\obj\Debug\SpeedComparsison.csprojResolveAssemblyReference.cache -C:\Users\Artem Los\Documents\GitHub\SKGL\SpeedComparsison\bin\Debug\SpeedComparsison.dll -C:\Users\Artem Los\Documents\GitHub\SKGL\SpeedComparsison\bin\Debug\SpeedComparsison.pdb -C:\Users\Artem Los\Documents\GitHub\SKGL\SpeedComparsison\bin\Debug\SKGL.dll -C:\Users\Artem Los\Documents\GitHub\SKGL\SpeedComparsison\bin\Debug\SKGL.pdb -C:\Users\Artem Los\Documents\GitHub\SKGL\SpeedComparsison\obj\Debug\SpeedComparsison.dll -C:\Users\Artem Los\Documents\GitHub\SKGL\SpeedComparsison\obj\Debug\SpeedComparsison.pdb diff --git a/SpeedComparsison/obj/Debug/SpeedComparsison.csprojResolveAssemblyReference.cache b/SpeedComparsison/obj/Debug/SpeedComparsison.csprojResolveAssemblyReference.cache deleted file mode 100644 index 07893c2..0000000 Binary files a/SpeedComparsison/obj/Debug/SpeedComparsison.csprojResolveAssemblyReference.cache and /dev/null differ diff --git a/SpeedComparsison/obj/Debug/SpeedComparsison.dll b/SpeedComparsison/obj/Debug/SpeedComparsison.dll deleted file mode 100644 index 1bc97dc..0000000 Binary files a/SpeedComparsison/obj/Debug/SpeedComparsison.dll and /dev/null differ diff --git a/SpeedComparsison/obj/Debug/SpeedComparsison.pdb b/SpeedComparsison/obj/Debug/SpeedComparsison.pdb deleted file mode 100644 index bb73e3c..0000000 Binary files a/SpeedComparsison/obj/Debug/SpeedComparsison.pdb and /dev/null differ