123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "EncryptionF.h"
- #pragma hdrstop
- #include "FrmMainF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxEdit"
- #pragma link "cxGraphics"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxMaskEdit"
- #pragma link "cxSpinEdit"
- #pragma link "cxTextEdit"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinMcSkin"
- #pragma link "dxSkinsCore"
- #pragma link "cxButtons"
- #pragma link "cxDropDownEdit"
- #pragma resource "*.dfm"
- TFrmMain *FrmMain;
- //---------------------------------------------------------------------------
- __fastcall TFrmMain::TFrmMain(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmMain::cboLicenseTypePropertiesChange(TObject *Sender)
- {
- bool isVisible = false;
- if (cboLicenseType->ItemIndex == 0) {
- isVisible = true;
- }
- //lblIssueDays->Enabled = isVisible;
- seIssueDays->Enabled = isVisible;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmMain::btnHostNameClick(TObject *Sender)
- {
- char szNom[512];
- DWORD size = 512;
- GetComputerName(szNom, &size);
- txtHostName->Text = String(szNom);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmMain::btnLicenseGenerateXmlClick(TObject *Sender)
- {
- moLicenseXml->Lines->Clear();
- GUID guid;
- CoCreateGuid(&guid);
- //UUID uuid;
- //UuidCreateSequential(&uuid);
- String product = "AIP Gateway";
- String serialId = GUIDToString(guid);
- serialId = StringReplace(serialId, "{", "", TReplaceFlags() << rfReplaceAll);
- serialId = StringReplace(serialId, "}", "", TReplaceFlags() << rfReplaceAll);
- String issueDay = Now().FormatString("YYYY-MM-DD");
- String licensee = txtHostName->Text.Trim();
- String edition = cboProductType->ItemIndex == 0 ? "standard" : "enterprise";
- String type = cboLicenseType->ItemIndex == 0 ? "demo" : "product";
- String accounts = String((int)seLicenseCnt->Value);
- String identifiedHost = txtHostName->Text.Trim();
- AnsiString endKey = product.UpperCase() + "hanteinfo12#$!" + serialId.LowerCase() + issueDay + edition.UpperCase() + type.LowerCase() + AnsiString((int)seLicenseCnt->Value + 10000) + identifiedHost.LowerCase();
- String signature = ITSSHA256_Encrpyt(endKey);;
- String demoDuration = String((int)seIssueDays->Value);
- moLicenseXml->Lines->Add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- moLicenseXml->Lines->Add("<aip_license>");
- moLicenseXml->Lines->Add(" <license version=\"1.0\">");
- moLicenseXml->Lines->Add(" <product version=\"2\">" + product + "</product>");
- moLicenseXml->Lines->Add(" <serialId>" + serialId + "</serialId>");
- moLicenseXml->Lines->Add(" <issueDay>" + issueDay + "</issueDay>");
- //moLicenseXml->Lines->Add(" <licensee>" + licensee + "</licensee>");
- moLicenseXml->Lines->Add(" <edition>" + edition + "</edition>");
- moLicenseXml->Lines->Add(" <type>" + type + "</type>");
- moLicenseXml->Lines->Add(" <accounts>" + accounts + "</accounts>");
- moLicenseXml->Lines->Add(" <identifiedHost>" + identifiedHost + "</identifiedHost>");
- moLicenseXml->Lines->Add(" <signature>" + signature + "</signature>");
- if (type == "demo") {
- moLicenseXml->Lines->Add(" <demoDuration>" + demoDuration + "</demoDuration>");
- }
- moLicenseXml->Lines->Add(" </license>");
- moLicenseXml->Lines->Add("</aip_license>");
- moLicenseXml->Lines->Add("");
- }
- //---------------------------------------------------------------------------
|