Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 31 total
Thread Encryption
Sat, Oct 18 2008 1:21 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

I'm going to want encrypt a small file or two as part of an app. Is there a way of accessing the encryption you've built into ElevateDB?


Roy Lambert
Mon, Oct 20 2008 3:15 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< I'm going to want encrypt a small file or two as part of an app. Is there
a way of accessing the encryption you've built into ElevateDB? >>

Sure.  You can use it via the edbcommon unit and the TEDBBlowfish object.
Although, the easiest way might be to simply use the TEDBMemoryStream in the
the edbcommon.pas unit, which has these methods:

        procedure InitEncryption(PasswordDigest: TEDBDigest);
        procedure Encrypt(Count: Integer=0);
        procedure Decrypt(Count: Integer=0);

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Oct 21 2008 4:40 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

Brill - thanks.

Roy Lambert
Wed, Feb 25 2009 3:36 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

I've reached a point where I want to test things out. I've tried:



procedure TForm1.AdvGlowButton1Click(Sender: TObject);
var
interim: string;
ts: TEDBMemoryStream;
bf: TEDBDigest;
begin
if Saver.Execute then begin
 interim := Trim(Licencee.Text) + '¬' + MaxUsers.Text + '¬' + LicenceCode.Text;
 ts := TEDBMemoryStream.Create;
 bf := TEDBDigest.Create;
 bf.AsString := 'roylambert';
 ts.InitEncryption(bf);
 ts.WriteString(interim, Length(interim));
 ts.Encrypt(Length(interim));
 TMemoryStream(ts).SaveToFile(Saver.FileName);
end;
end;

This works until I include ts.Encrypt(Length(interim)); then I get strange results

---------------------------
Lm
---------------------------
Cannot create file "”:\Users\Roy Lambert\Documents\xxx.tfr". The system cannot find the path specified.
---------------------------
OK  
---------------------------

I'm obviously doing something wrong, but I have no idea what.

Roy Lambert
Wed, Feb 25 2009 9:46 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< This works until I include ts.Encrypt(Length(interim)); then I get
strange results >>

What the heck is this:

TMemoryStream(ts).SaveToFile(Saver.FileName);

TEDBMemoryStream is *not* a descendant of TMemoryStream or TStream.

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Feb 25 2009 10:28 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim


1. The rest is alright though?
2. Consider me an innocent victim of your naming scheme Smiley

Roy Lambert
Wed, Feb 25 2009 10:41 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< 1. The rest is alright though? >>

Yes.

<< 2. Consider me an innocent victim of your naming scheme Smiley>>

Well, originally it was a descendant of TStream, but I had to change that
all around due to .NET and various issues with trying to override all of the
variations the TStream methods have taken over the years since D5.

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Feb 25 2009 11:32 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim


Once I've got it in there how do I get at the encrypted version to save it? I've been trying various things but nothing works so far.

Roy Lambert
Fri, Feb 27 2009 8:06 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< Once I've got it in there how do I get at the encrypted version to save
it? I've been trying various things but nothing works so far. >>

You can access the memory buffer directly using the Memory property.
However, I forgot that there's a TEDBStreamWrapper class defined in
edbcomps.pas.  You create it like this:

constructor TEDBStreamWrapper.Create(SourceStream: TStream);

which means that you can use it to interface between a normal TStream and a
TEDBStream (or descendant like TEDBMemoryStream).

You would use it like this:

var
   MyFileStream: TFileStream;
   MyStreamWrapper: TEDBStreamWrapper;
   MyMemoryStream: TEDBMemoryStream;
begin
   MyFileStream:=.....
   MyStreamWrapper:=TEDBStreamWrapper.Create(MyFileStream);
   MyMemoryStream:=....
   // Work with the memory stream, encrypt it, etc.
   MyMemoryStream.SaveToStream(MyStreamWrapper);
   // Free everything up here, etc.
end;

And that should do the trick.

--
Tim Young
Elevate Software
www.elevatesoft.com

Fri, Feb 27 2009 10:29 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

>However, I forgot that there's a TEDBStreamWrapper class defined in
>edbcomps.pas.

Glad I'm not the only one that does that SmileyUnfortunately its not exposed, but I'm happy to work with the Memory property. One (hopefully) final question: How do I decrypt it?

I can stuff my data in and encrypt it and using

for cntr := 1 to Length(ts.Memory) do xyz:=xyz+char(ts.memory[cntr]);

get it out to have a look at (strangely with my data the last few characters are always in the clear).

What I'm doing now as a test is

interim := Trim(Licencee.Text) + '¬' + MaxUsers.Text + '¬' + LicenceCode.Text;
ts := TEDBMemoryStream.Create;
bf := TEDBDigest.Create;
bf.AsString := '1qw'+#8+#160+'roylambertqw42ecccrtyuiopasdfghjkl';
ts.InitEncryption(bf);
ts.WriteString(interim, Length(interim));
ts.Position := 0;
ts.Encrypt(Length(interim));
ts.Position := 0;
ts.Decrypt(length(ts.Memory));
ts.Position := 0;
for cntr := 1 to Length(ts.Memory) do xyz:=xyz+char(ts.memory[cntr]);
showmessage(inttostr(length(xyz))+'   '+xyz);
bf.Free;
ts.Free;

Roy Lambert
Page 1 of 4Next Page »
Jump to Page:  1 2 3 4
Image