TurboPack / LockBox3

LockBox3 is a Delphi and C++Builder library for cryptography.
Other
173 stars 59 forks source link

TCodec.DecryptString compatibility #13

Closed leocecchet closed 3 years ago

leocecchet commented 4 years ago

Hello. I made a comment on another closed topic #4 at the following link: https://github.com/TurboPack/LockBox3/issues/4#issuecomment-583006320

The code I used is as follows:

function Cript(const psKey, psText: String; const pbEncrypt: Boolean): String;
const
  sKEY = '{0BC16F6A-A80E-4849-88C8-C6BBD57F7A19}'

begin
  Codec.StreamCipherId := BlockCipher_ProgId; //  'native.StreamToBlock'
  Codec.BlockCipherId := 'native.AES-256';
  Codec.ChainModeId := CBC_ProgId; // 'native.CBC'

  if Trim(psKey) = EmptyStr then
    Codec.Password := sKEY
  else
    Codec.Password := psKey;

  if pbEncrypt then
    Result := Codec.EncryptString(psTexto, Result, TEncoding.Default)
  else
    Result := Codec.DecryptString(Result, psText, TEncoding.Default);
end;

DFM:

object CryptographicLibrary: TCryptographicLibrary
    Left = 45
    Top = 15
  end
  object Codec: TCodec
    AsymetricKeySizeInBits = 1024
    AdvancedOptions2 = []
    CryptoLibrary = CryptographicLibrary
    Left = 45
    Top = 72
    StreamCipherId = 'native.StreamToBlock'
    BlockCipherId = 'native.AES-256'
    ChainId = 'native.CBC'
  end

Can anyone help?

romankassebaum commented 3 years ago

I fear I cannot help since Sean has written these components. His website is here: http://www.lockbox.seanbdurkin.id.au.