Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 09/15/23 in all areas

  1. Remy Lebeau

    Installing Indy 10 on Delphi 7

    What @DelphiUdIT said. Indy 10 does have .dpk package files for Delphi 7, namely: IndySystem70.dpk IndyCore70.dpk IndyProtocols70.dpk dclIndyCore70.dpk dclIndyProtocols70.dpk
  2. DelphiUdIT

    Installing Indy 10 on Delphi 7

    You can start from here: https://github.com/IndySockets/Indy/wiki/Updating-Indy
  3. Pat Foley

    ProcessMessages doesn't seem to update controls

    Here's a pascal example that simply replaces ProcessMessages with custom "message" calls to allow the sleep delays. assign this ClickEvent to several buttons onclick Event. I would look media player source for dealing with updating several buttons state. implementation {$R *.dfm} const Clickable = True; // alias for enabled = True procedure ButtonEnable(button: TButton; const aCaption: string; const isEnabled: Boolean); //inline; begin if button.Enabled <> isEnabled then button.Enabled := isEnabled; if button.Caption <> aCaption then button.Caption := aCaption; // button.Enabled := isEnabled; order matters //Button.Repaint; // end; procedure SnoozedButton(button: TButton; MS: Integer); //inline; begin ButtonEnable(button, 'Snoozed', not Clickable); Sleep(MS); end; var inUse: Boolean = False; procedure TForm15.DealButtonClick(Sender: TObject); begin if inUse = not False then exit; inUse := True;//Sender as TButton; SnoozedButton(Sender as TButton, 3000); ButtonEnable(Sender as TButton, 'Hit me', not Clickable); Sleep(1500); (Sender as TButton).Caption := 'Hitted'; sleep(1500); sleepControl(Sender, 2000); // Event driven call ButtonEnable(Sender as TButton, 'Deal', Clickable); inUse := False;//nil; end; procedure TForm15.sleepControl(Sender: TObject; const MS: Integer); begin var button := Sender as TButton; ButtonEnable(button, 'Sleeping', not Clickable); Sleep(MS); ButtonEnable(button, 'Stay', not Clickable); Sleep(MS); end; I think that's a feature🙂. I would like the showhint to work when the button is disabled.
  4. DelphiUdIT

    Installing Indy 10 on Delphi 7

    I use these (it's for Delphi 11.3 and Indy from github).
  5. Testing testing 1 2 3 Done...exiting Your encrypted text, if case you didn't solved this yet, here is the fixed code const cPassphrase = 's0m3s3cr3t!'; procedure CryptoError; var LError: TBytes; LMessage: string; begin SetLength(LError, 120); ERR_load_crypto_strings; ERR_error_string_n(ERR_get_error, @LError[0], Length(LError)); LMessage := TEncoding.UTF8.GetString(LError); // Display the message Writeln(LMessage); end; function DecryptAES256(const AValue: string): string; var LContext: PEVP_CIPHER_CTX; LOutputLen, LFinalLen: Integer; LBytes, LSalt, LIV, LEncryptedText, LKey, LOutput: TBytes; LCipher: Pointer; begin Result := ''; LBytes := TNetEncoding.Base64.DecodeStringToBytes(AValue); LCipher := EVP_aes_256_cbc; // prepare Key and IV length SetLength(LKey, EVP_CIPHER_key_length(LCipher)); SetLength(LIV, EVP_CIPHER_iv_length(LCipher)); // crypto-js returns an OpenSSL result, i.e. "salted__" + salt + encrypted text LEncryptedText := Copy(LBytes, 16, MaxInt); // Calc key and IV from passphrase and salt , crypto-js by default uses KDF with (MD5/8 bytes Salt/1 iteration) // https://github.com/brix/crypto-js/blob/develop/src/evpkdf.js LSalt := Copy(LBytes, 8, 8); if EVP_BytesToKey(LCipher, EVP_md5, @LSalt[0], @AnsiString(cPassphrase)[1], Length(cPassphrase), 1, @LKey[0], @LIV[0]) > 0 then begin LContext := EVP_CIPHER_CTX_new(); // Set padding EVP_CIPHER_CTX_set_padding(LContext, EVP_PADDING_PKCS7); if LContext <> nil then try // Initialize the decryption operation with 256 bit AES if EVP_DecryptInit_ex(LContext, LCipher, nil, @LKey[0], @LIV[0]) = 1 then begin SetLength(LOutput, Length(LEncryptedText) + EVP_CIPHER_block_size(LCipher)); // Provide the message to be decrypted, and obtain the plaintext output if EVP_DecryptUpdate(LContext, @LOutput[0], @LOutputLen, @LEncryptedText[0], Length(LEncryptedText)) = 1 then begin if EVP_DecryptFinal_ex(LContext, @LOutput[LOutputLen], @LFinalLen) = 1 then begin Inc(LOutputLen, LFinalLen); SetLength(LOutput, LOutputLen); Result := TEncoding.UTF8.GetString(LOutput); // might raise an unanticipated exception, should be inside try-except //Result := StringOf(LOutput); // IMO, this is safer than risking raising an exception end else CryptoError; end else CryptoError; end else CryptoError; finally EVP_CIPHER_CTX_free(LContext); end; end else CryptoError; end; begin // Decrypt value output by crypto-js // This is just an example value. Generate a new one from the Javascript code Writeln(DecryptAES256('U2FsdGVkX1812TdTm8MD2w4u2AaxUB2PdurCNOmu4bmutkR1Ul7Z1+bGXDsdlNK5')); Writeln('Done...exiting'); Readln; end. I recommend double check string Unicode on java part and how the above code will behave.
  6. Angus Robertson

    OpenSLL Dlls path

    There are several global variables used to determine how OpenSSL is loaded, this chunk of code is from the OverbyteIcsHttpRestTst1 unit, but most ICS samples have something similar. // Avoid dynamical loading and unloading the SSL DLLs plenty of times // GSSLEAY_DLL_IgnoreNew := True; { ignore OpenSSL 3.0 and later } // GSSLEAY_DLL_IgnoreOld := True; { ignore OpenSSL 1.1 } // note both not allowed true GSSL_DLL_DIR := FProgDir; { only from our directory } GSSL_SignTest_Check := True; { check digitally signed } GSSL_SignTest_Certificate := True; { check digital certificate } OverbyteIcsWSocket.LoadSsl; if NOT GSSLStaticLinked then begin if NOT FileExists (GLIBEAY_DLL_FileName) then LogWin.Lines.Add('SSL/TLS DLL not found: ' + GLIBEAY_DLL_FileName) else LogWin.Lines.Add('SSL/TLS DLL: ' + GLIBEAY_DLL_FileName + ', Version: ' + OpenSslVersion); end else LogWin.Lines.Add('SSL/TLS Static Linked, Version: ' + OpenSslVersion); This version ensures the DLLs are only loaded from our own directory using GSSL_DLL_DIR, since Windows may have dozens of different versions of the DLLs scattered around the drive from different applications. The code loads OpenSSL once and tells you what version it found and where, and whether YuOpenmSSL is being used which avoids all DLL problems. Might have to revisit the IgnoreNew/Old stuff since 1.1 is now out of support. Angus
  7. Fr0sT.Brutal

    ProcessMessages doesn't seem to update controls

    Seems the easiest solution is to delay an action via timer. Disable buttons, create timer with interval ~200ms and do your action in its OnTimer.
  8. Remy Lebeau

    ProcessMessages doesn't seem to update controls

    Yes, it does. But it can only handle messages that are already in the message queue (or synthetically generated by the queue) at the moment it is called. It does not process future messages. And the behavior you describe sounds like the actions are being delayed such that ProcessMessages() doesn't see all of them right away, which is why calling ProcessMessages() multiple times produces better results. You really should not be using ProcessMessages() in this manner in the first place. Break up your code logic using TThread::ForceQueue() or a TTimer or equivalent to allow control to flow back into the main message loop so it can continue to process new messages while your desired time interval is waiting to elapse. For example, using TThread::ForceQueue(): void __fastcall TForm1::Button1Click(TObject *Sender) { Button1->Enabled = false; Button2->Enabled = false; Button3->Enabled = false; TThread::ForceQueue(nullptr, &Step2, 3000); } void __fastcall TForm1::Step2() { Button1->Enabled = true; Button2->Enabled = true; Button3->Enabled = true; TThread::ForceQueue(&Step3, 3000); } void __fastcall TForm1::Step3() { //... } // alternatively void __fastcall TForm1::Button1Click(TObject *Sender) { Button1->Enabled = false; Button2->Enabled = false; Button3->Enabled = false; TThread::ForceQueue(nullptr, [this](){ Button1->Enabled = true; Button2->Enabled = true; Button3->Enabled = true; TThread::ForceQueue(nullpr, [](){ //... }, 3000); }, 3000); } Or, using TTimer: void __fastcall TForm1::Button1Click(TObject *Sender) { Button1->Enabled = false; Button2->Enabled = false; Button3->Enabled = false; //Timer1->Interval = 3000; Timer1->Tag = 1; Timer1->Enabled = true; } void __fastcall TForm1::Timer1Timer(TObject *Sender) { if (Timer1->Tag == 1) { Button1->Enabled = true; Button2->Enabled = true; Button3->Enabled = true; //Timer1->Interval = 3000; Timer1->Tag = 2; } else { //... Timer1->Enabled = false; Timer1->Tag = 0; } } // alternatively... void __fastcall TForm1::Button1Click(TObject *Sender) { Button1->Enabled = false; Button2->Enabled = false; Button3->Enabled = false; //Timer1->Interval = 3000; Timer1->OnTimer = Step2; Timer1->Enabled = true; } void __fastcall TForm1::Step2(TObject *Sender) { Button1->Enabled = true; Button2->Enabled = true; Button3->Enabled = true; //Timer1->Interval = 3000; Timer1->OnTimer = Step3; } void __fastcall TForm1::Step3(TObject *Sender) { //... Timer1->Enabled = false; Timer1->OnTimer = nullptr; }
  9. This project deserves some attention (greenlets-coroutines, generators, channels and more). It is based on fibers.
  10. mezen

    Indy & OpenSSL 1.1.1 & TLS 1.3

    I wrote on the PR a comment some days ago. tl;dr: Stopped on that PR, currently working on OpenSSL 3, will create a new PR when its done.
×