Jump to content
ertank

AES Encryption - FMX

Recommended Posts

Hello,

 

There seems to be a lot of VCL based free solutions. I could not find one for FMX platform.

 

I am looking for a free AES256-CBC FMX compatible solution that I can pass IV and Key values manually.

 

I installed "LockBox VCL and FMX 2.3" from GetIt package manager. It seems to take string value as Key for TLbRijndael component and does everything internally.

 

Any help is appreciated.

 

Thanks & regards,

Ertan

Share this post


Link to post

Encryption is agnostic of framework. I don't see how you could have a VCL only encryption library. You don't need design time components. 

  • Like 1
  • Thanks 1

Share this post


Link to post
2 minutes ago, David Heffernan said:

Encryption is agnostic of framework. I don't see how you could have a VCL only encryption library. You don't need design time components. 

I mostly use mORMot for my AES handling. Even it compiles on Linux FPC and Raspberry Pi, it doesn't compile for FMX. First compiler complaint is about AnsiString type.

 

I tried pure Pascal Wolfgang Ehrhardt library and compiler is not happy with internal used type declarations in BType.pas file like

type

  Str255 = string[255];

 

So I'm asking for help from anyone who used an AES encryption under FMX.

Share this post


Link to post
7 minutes ago, David Heffernan said:

Encryption is agnostic of framework. I don't see how you could have a VCL only encryption library. You don't need design time components. 

Unless someone designed framework poorly. 

 

There is also possibility that framework is only for Windows and cannot be used as cross-platform solution. Still, people might use FMX only on Windows, so naming framework VCL would be poor choice in such case.

  • Thanks 1

Share this post


Link to post
1 minute ago, ertank said:

I mostly use mORMot for my AES handling. Even it compiles on Linux FPC and Raspberry Pi, it doesn't compile for FMX. First compiler complaint is about AnsiString type.

Depending on how AnsiString is used, it can be replaced with RawByteString in cross-platform. Only if it interprets stored characters and makes conversions, it cannot.

Share this post


Link to post
4 minutes ago, Dalija Prasnikar said:

Depending on how AnsiString is used, it can be replaced with RawByteString in cross-platform. Only if it interprets stored characters and makes conversions, it cannot.

It is just there are internal references and functions using that type. Moreover, it includes about 65kb big commonly used unit that needs a lot more modifications than converting AnsiString that I don't want to dig into.

Edited by ertank

Share this post


Link to post

I could use CryptoLib4Pascal cross-platform successfully with help from @Ugochukwu Mmaduekwe

 

My test code looks like following:

uses
  System.NetEncoding,
  ClpIBufferedCipher,
  ClpCipherUtilities,
  ClpIParametersWithIV,
  ClpParametersWithIV,
  ClpParameterUtilities;

procedure TForm2.Button1Click(Sender: TObject);
var
  Cipher: IBufferedCipher;
  KeyParametersWithIV: IParametersWithIV;
  KeyBytes: TBytes;
  IVBytes: TBytes;
  Buf: TBytes;
  PlainText: TBytes;
begin
  KeyBytes := [31,32,33,34,35,36,37,38,39,30,31,32,33,34,35,36,37,38,39,30,31,32,33,34,35,36,37,38,39,30,31,32];
  IVBytes := [31,32,33,34,35,36,37,38,39,30,31,32,33,34,35,36];
  PlainText := TEncoding.UTF8.GetBytes(Edit1.Text);

  Cipher := TCipherUtilities.GetCipher('AES/CBC/PKCS7PADDING');

  KeyParametersWithIV := TParametersWithIV.Create(TParameterUtilities.CreateKeyParameter('AES', KeyBytes), IVBytes);

  Cipher.Init(True, KeyParametersWithIV); // init encryption cipher

  Buf := Cipher.DoFinal(PlainText);

  Edit2.Text := TNetEncoding.Base64.EncodeBytesToString(Buf);
end;

One who wants to use framework needs to put all directories & sub directories in Library Path, or use provided run-time packages. I did the former.

 

Share this post


Link to post

I think that the free FMX TurboPower Lockbox offers AES encryption and it works on any platform.
Did check whether AES256 is supported, but it's worth a look.
Install it via GetIt

  • Like 1

Share this post


Link to post
On 9/22/2019 at 11:22 AM, Dalija Prasnikar said:

Unless someone designed framework poorly. 

 

There is also possibility that framework is only for Windows and cannot be used as cross-platform solution. Still, people might use FMX only on Windows, so naming framework VCL would be poor choice in such case.

You are right, SynCrypto is fine with FMX running on Windows - and it uses RawByteString or TBytes as required since Delphi 2009. But it is not a OS compatibility problem - it is a compiler issue.
To be fair, it's Delphi cross-platform compiler/RTL which is designed poorly, especially all the backward compatibility breaks they made about strings and heap.
Their recent step back is a clear hint of their bad design choices.

There is no problem to use SynCrypto on Windows, Linux, BSD, Darwin, for Intel/AMD or ARM 32-bit or 64-bit CPU, if you use FPC.
But we didn't lose time with targets breaking too much the existing code base. I am happy I didn't spend weeks making mORMot ARC-compatible - which is now deprecated! - and focused instead on FPC compatibility and tuning. Which was very rewarding.

Edited by Arnaud Bouchez
  • Like 2

Share this post


Link to post
On 9/22/2019 at 8:12 AM, ertank said:

I am looking for a free AES256-CBC FMX compatible solution that I can pass IV and Key values manually.

 

1 hour ago, Jose Morango said:

HI,

Try  Tms CryptoGrapy Pack, runs on VCL, FMX, I'm using it on my android and iOS apps adn it work just fine.

 

 

Note the key word free in the original poster question.

Share this post


Link to post
2 minutes ago, Ugochukwu Mmaduekwe said:

 

Note the key word free in the original poster question.

Hi Ugochukwu,

Sorry Ii didn't pay  attention to the "Free" word,

but sometimes when we measure all the time and work time that we lost finding the rigth free tool It is better to buy one, dependind of course of the cost vs profit of the project we working on.

 

 

Share this post


Link to post
31 minutes ago, sjordi said:

Did you try TurboPower Lockbox ? It's free

I failed to find a way to manually provide key and IV for AES256-CBC as byte values for that component set.

 

However, as already indicated I use CryptoLib4Pascal successfully on VCL and FMX with help from @Ugochukwu Mmaduekwe

 

  • Like 1

Share this post


Link to post
On 9/23/2019 at 8:13 AM, sjordi said:

I think that the free FMX TurboPower Lockbox offers AES encryption and it works on any platform.
Did check whether AES256 is supported, but it's worth a look.
Install it via GetIt

Hi,

 

For 10.4, getit gives an error, I could not reach the developer.
How can I install for 10.4?

Share this post


Link to post
17 hours ago, pro_imaj said:

Hi,

 

For 10.4, getit gives an error, I could not reach the developer.
How can I install for 10.4?

From Petit I select LockBox 3.7 and install it without troubles.

If asked to continue executing the script, say yes.

You can't contact the developer. TurboPower doesn't exist any longer, for more than 10 years.

But they were nice enough to release the source code. You might find them on Github and create issues tickets there if required.

 

By the way, it seems to not support iOS. Only Windows, macOS and Android.

 

Share this post


Link to post
38 minutes ago, sjordi said:

From Petit I select LockBox 3.7 and install it without troubles.

If asked to continue executing the script, say yes.

You can't contact the developer. TurboPower doesn't exist any longer, for more than 10 years.

But they were nice enough to release the source code. You might find them on Github and create issues tickets there if required.

 

By the way, it seems to not support iOS. Only Windows, macOS and Android.

 

I don't understand why it gives the attached error.
I try both.

 

*I use this component to support IOS.

 

 

Error.PNG

Share this post


Link to post

Are you within a professional environment like work? They may have a firewall and forbid the connection to the server.

Did you try with public Wifi or use your 4G connection on your smartphone as a hotspot to bypass possible restrictions?

 

It won't work for iOS unfortunately if I'm correct.

Steve

Share this post


Link to post

I wrote to the component developer, thank you, the problem is not caused by the component problem Delphi!

CMD was able to run smoothly when we ran this parameter. GetItCmd.exe -c = useonline

Edited by pro_imaj

Share this post


Link to post
Guest

@pro_imaj Please don't be offended by my words here.

 

You mentioned 10.4, and i want to ask of you found it on a side walk or bought it by real money ?,

if the latter then i would suggest to email Embarcadero support asking them to support their product and what version is working and what not ?, how to do it? , after all it is their job to provide you support worth of money you paid for, and please share with us their answer to be public knowledge and when it does come, some expert there added it to GetIt and of course he tested it, it is his job after all, right ?

So please email them.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×