Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
Thank you, it is what i was looking for. But IDK why it doesn´t work, it just add empty line im memo. I was looking for more methods, here they are in forum
https://forum.lazarus.freepascal.org/index.php?topic=33013.0, but it still just add empty line in memo
here is my code.

Code: Pascal  [Select]
  1. uses
  2.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, BlowFish;
  3.  
  4. type
  5.  
  6.   { TForm1 }
  7.  
  8.   TForm1 = class(TForm)
  9.     Button1: TButton;
  10.     Button2: TButton;
  11.     Button3: TButton;
  12.     Memo1: TMemo;
  13.     Memo2: TMemo;
  14.     OpenDialog1: TOpenDialog;
  15.     SaveDialog1: TSaveDialog;
  16.     procedure Button1Click(Sender: TObject);
  17.     procedure Button2Click(Sender: TObject);
  18.     procedure Button3Click(Sender: TObject);
  19.   private
  20.  
  21.   public
  22.  
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.   t: textfile;
  28.   s, Keyphrase: string;
  29.  
  30. implementation
  31.  
  32. {$R *.lfm}
  33.  
  34. { TForm1 }
  35.  
  36. procedure EncryptAndWriteToFile(Filename: string; KeyPhrase: string; Value: string);
  37. var
  38.   en: TBlowFishEncryptStream;
  39.   s1: TFileStream;
  40. begin
  41.   s1 := TFileStream.Create(Filename, fmCreate or fmOpenReadWrite);
  42.   en := TBlowFishEncryptStream.Create(KeyPhrase, s1);
  43.   try
  44.     en.WriteAnsiString(Value);
  45.   finally
  46.     en.Free; // important to free en first (need for flush to s1)
  47.     s1.Free;
  48.   end;
  49. end;
  50.  
  51. function DecryptFromMemo(AMemo: TMemo; keyphrase: String): String;
  52. var
  53.   de: TBlowFishDeCryptStream;
  54.   s1: TStringStream;
  55.   Value, temp: string;
  56. begin
  57.   Result := 'error';
  58.   s1 := TStringStream.Create(AMemo.Text);
  59.   try
  60.     de := TBlowFishDecryptStream.create(Keyphrase, s1);
  61.     try
  62.       Result := de.ReadAnsiString;
  63.     finally
  64.       de.Free;
  65.     end;
  66.   finally
  67.     s1.Free;
  68.   end;
  69. end;
  70.  
  71. procedure TForm1.Button1Click(Sender: TObject);
  72. begin
  73.   memo1.clear;
  74.   memo2.clear;
  75. end;
  76.  
  77. procedure TForm1.Button2Click(Sender: TObject);
  78. begin
  79.   KeyPhrase:='123';
  80.   if SaveDialog1.Execute then
  81.     EncryptAndWriteToFile(SaveDialog1.Filename, KeyPhrase, Memo1.Lines.Text);
  82. end;
  83.  
  84. procedure TForm1.Button3Click(Sender: TObject);
  85. begin
  86.  
  87.   OpenDialog1.Filter := 'All Files|*.txt';
  88.     if opendialog1.execute then
  89.     begin
  90.      assignfile(t,opendialog1.filename);
  91.      reset(t);
  92.  
  93.      while not  eof(t) do
  94.   begin
  95.     ReadLn(t,s);
  96.     memo2.lines.add(s);
  97.   end;
  98.      KeyPhrase:='123';
  99.     Memo1.lines.add(DecryptFromMemo(Memo2, Keyphrase));
  100.  
  101. end;
  102.  
  103. end;
  104. end.
any ideas what should i do?
2
Databases / FirebirdSQL Win1250 question
« Last post by k1attila1 on Today at 07:12:35 pm »
Hi

I try to use in my application FB2.5 with win1250 cp.

But in dbedit i have problem.
When i type the text everything is OK, but when i leave the dbedit something go wrong.
See attachments.

Any idea ? What is wrong ?


3
General / Re: INPUT - OUTPUT via USB
« Last post by MarkMLl on Today at 06:28:18 pm »
I've told you what to look for, and that's as much as any of us can do.

You might need to check out Comedi, but I don't know whether that has Windows support.
4
Mac OS X / Re: Mac OS serial port access
« Last post by MarkMLl on Today at 06:26:47 pm »
With the important caveat that it's only- as far as I know- been tested in Windows, Linux and Solaris. The thing to watch out for is the precise behaviour of the select() function, see the comments which should be adequately detailed and please make the core developers aware if you can conclusively say that the unit works properly /including/ the various timeouts.
5
Graphics / Re: Evaluate a physical questionnaire
« Last post by circular on Today at 06:09:29 pm »
You could try to identify certain elements and from there determine an affine box. From there if elements have a predefined position you could check those locations
6
General / Re: Usage of append
« Last post by lucamar on Today at 05:29:07 pm »
Something like Append() for non-text files may be like this:

Code: Pascal  [Select]
  1. type
  2.   TMyrecord = packed record
  3.     a:byte;
  4.     b:longint;
  5.   end;
  6.   TMyFile = file of TMyrecord;
  7.  
  8. var
  9.   F:TMyFile;
  10.  
  11. procedure OpenToAppend(var AFile: TMyFile; Filename: String);
  12. begin
  13.   Assign(AFile, Filename);
  14.   Reset(AFile);
  15.   Seek(AFile, FileSize(AFile));
  16. end;

Error-checking is left as an execise for the reader :)
7
Graphics / Evaluate a physical questionnaire
« Last post by Nomos on Today at 05:26:40 pm »
I want to create a software that evaluates ticked check boxes in a - physical - multiple choice questionnaire. After filling out the forms are scanned and are then available as a TIFF file in a reserved directory. The number of forms is arbitrary.

I don't expect a finished solution however, i would be grateful for one or the other suggestion.

Regards
Nomos
8
Windows / Re: What's the meaning of dllparam in TDLL_Entry_Hook ?
« Last post by 440bx on Today at 05:07:21 pm »
No, that's true. But it is correct.... Delphi2 is the first 32 bit version and did not mature, just like you... I would not rely on comparing D2 "features" to FPC. Start comparing from something like D7
At least you're funny.... that's a plus.
9
Windows / Re: What's the meaning of dllparam in TDLL_Entry_Hook ?
« Last post by Thaddy on Today at 05:01:37 pm »
No, that's true. But it is correct.... Delphi2 is the first 32 bit version and did not mature, just like you... I would not rely on comparing D2 "features" to FPC. Start comparing from something like D7.
Btw sometimes I still use D2 because it renders smaller executables at the cost of non-fixed compiler bugs.
10
General / Re: Usage of append
« Last post by Thaddy on Today at 04:48:42 pm »
Bart was right. Append seems to only work for text files.  (AFAIK in ISO mode that is wrong)
That does not mean it is really an issue.

Example:
Code: Pascal  [Select]
  1. type
  2.   TMyrecord = packed record
  3.     a:byte;
  4.     b:longint;
  5.   end;
  6.  
  7.   TMyFile = file of TMyrecord;
  8.  
  9. var
  10.   F:TMyFile;
  11.   a:TMyRecord;
  12. begin
  13. { write part }
  14.   Assign (f,'test.txt');
  15.   Rewrite (f);            
  16.   a.a := 1;
  17.   a.b :=1000;
  18.   write(f,a);
  19.   inc(a.a); { modify the record }
  20.   write(f,a); { does append }
  21.   Close(f);
  22.   a:= default(TMyrecord); { clear a }
  23. { read part }
  24.   Assign(f,'test.txt');
  25.   reset(f);
  26.   while not eof(f) do
  27.   begin
  28.     Read(f,a);
  29.     writeln(a.a);
  30.     writeln(a.b);
  31.  end;  
  32. end.
Pages: [1] 2 3 ... 10