Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8388901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:34:34+00:00 2026-06-09T18:34:34+00:00

I use following procedure to encode stream. procedure SaveEncodedStream(Strm:TStream; LicFileName:String); var C:TCodec; CL:TCryptographicLibrary; Sg:TSignatory;

  • 0

I use following procedure to encode stream.

procedure SaveEncodedStream(Strm:TStream; LicFileName:String);
var
   C:TCodec;
    CL:TCryptographicLibrary;
    Sg:TSignatory;
    KFS,DFS:TFileStream;
    Dir:String;
begin
   CL:=TCryptographicLibrary.Create(nil);
   C:=TCodec.Create(nil);
  SG:=TSignatory.Create(nil);

   Dir :=  ExtractFilePath(ParamStr(0));
   KFS:=TFileStream.Create(Dir+PublicKeyFile,fmOpenRead);
   DFS:=TFileStream.Create(LicFileName,fmCreate);

  try
  C.CryptoLibrary:=CL;
  C.BlockCipherId := 'native.RSA';
  C.ChainModeId := 'native.CBC';
  C.AsymetricKeySizeInBits := 1024;
  SG.Codec:=C;
  SG.LoadKeysFromStream(KFS,[partPublic]);
  C.EncryptStream(Strm,DFS);
 finally
  CL.Free;
  C.Free;
  SG.Free;
  KFS.Free;
  DFS.Free;
 end;
end;

And receive “Wrong Mode” error on

C.EncryptStream(Strm,DFS); call

Stepping into the code I discovered that it even does not try to load keys as Codec is not initialized. When I place componets on the form – everything works. But I do not need Form or DataModule.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:34:36+00:00Added an answer on June 9, 2026 at 6:34 pm

    Have not found solution to get rid of DataModule. It looks like components need one to properly initialize themselves. So as workaround I have created global DataModule with all components configured in design mode. I use that module in SaveEncodedStream like that:

    uses 
      ... EncryptDataModule;
     ...
    var 
       BeenHere:Boolean = false;
     ...
    procedure SaveEncodedStream(Strm:TStream; LicFileName:String);
     var
       KFS,DFS:TFileStream;
       Dir:String;
    begin
    
       Dir :=  ExtractFilePath(ParamStr(0));
       KFS:=TFileStream.Create(Dir+PublicKeyFile,fmOpenRead);
       DFS:=TFileStream.Create(LicFileName,fmCreate);
    
       try
        DataModule.SG.LoadKeysFromStream(KFS,[partPublic]);
        if BeenHere then DataModule.C.Reset;  
        DataModule.C.EncryptStream(Strm,DFS);
        BeenHere:=true; 
      finally
       KFS.Free;
       DFS.Free;
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following mysql procedure, DROP PROCEDURE IF EXISTS `allied`.`GetRegistrationData`$$ CREATE DEFINER=`allied`@`%` PROCEDURE
I use the following function to show controls on my form: class procedure TFormMain.FadeControls(ctrl:Array
I use the following mysql query, DELIMITER $$ DROP PROCEDURE IF EXISTS `allied`.`aboutus_delete`$$ CREATE
I just use following code to add an image to my project, var paper
When i use following: var child:DisplayObjectContainer = dso.getChildAt( dso.numChildren -1 ) as DisplayObjectContainer; trace(child);
I'm trying to use the following stored procedure. DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteField`(
When coding in the Flash IDE, i very often use the following procedure to
I use the following stored procedure from my SQL Server 2008 database to return
Hi I use the following stored procedure,but i don't know how i use this
I'm trying to use following procedure in Delphi XE2 with Chromium component (version 306):

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.