I have try with this code but not work, I have test the function give me the same result:

var
  Cipher: TDCP_des;
  KeyStr: string;
  TextIn, TextOut : String;
  Hash: TDCP_sha1;
  Digest: array[0..19] of byte;
  Vector : array of Byte;

  src, enc, b64: TBytes;
  index, lunghezza, blocksize, paddingsize: integer;    

begin
    SetLength(Vector, 8);

  Vector[0] := 1;
  Vector[1] := 2;
  Vector[2] := 3;
  Vector[3] := 4;
  Vector[4] := 5;
  Vector[5] := 6;
  Vector[6] := 7;
  Vector[7] := 8;

  Cipher := TDCP_des.Create(Self);    
   Cipher.Init('cicciob1',Length('cicciob1')*8, addr(Vector[0]));
  TextIn := Edit1.Text;
  lunghezza := Length(TextIn);
  index := SizeOf(TextIn);
  blocksize := Cipher.BlockSize div 8;
  paddingsize:= blocksize - (lunghezza mod blocksize);
  Inc(lunghezza, paddingsize);
  SetLength(TextIn, lunghezza);
  for index:=paddingsize downto 1 do
  begin
       TextIn[lunghezza - index] := char(0);
  end;
  index := Length(TextOut);
  SetLength(TextOut, lunghezza);
  Cipher.EncryptCBC(TextIn[1], TextOut[1], length(TextIn));
  Edit2.Text:=EncodeStringBase64(TextOut);    






Il 15/11/2015 11:59, Sven Barth ha scritto:

Am 15.11.2015 06:31 schrieb "Gabriele Cappelletto" <[email protected]>:
>
>
>
> Il 14/11/2015 18:11, Graeme Geldenhuys ha scritto:
> > On 2015-11-14 09:44, Gabriele Cappelletto wrote:
> >> the .net DESCryptoServiceProvider.
> > Please show how the data was encrypted... The exact code snippet would
> > be useful. I could then show you how to use DCPCrypt with the same
> > settings to decrypt it.
> >
> > Without knowing how it was encrypted, there is no way anybody can show
> > you code on how to decrypt it.
> >
> > Regards,
> >   - Graeme -
> > Ok thanks. We start from the opposite. cryptographer a string with vb.net with the following code, what's the code to decrypt it with DCPCrypt?
>
> Ok thanks. We start from the opposite. cryptographer a string with
> vb.net with the following code, what's the code to decrypt it with DCPCrypt?
>
>         Dim Key() As Byte = {}
>         Dim IV() As Byte = {1, 2, 3, 4, 5, 6, 7, 8}
>
>         Dim KeyStr As String = "cicciob1"
>         Dim vector As String = "12345678"
>         Dim inputByteArray(TextBox3.Text.Length) As Byte
>         Dim des As New DESCryptoServiceProvider
>         'des.Mode = CipherMode.CBC
>         'des.Padding = PaddingMode.Zeros
>         Key = System.Text.Encoding.UTF8.GetBytes(KeyStr)
>         inputByteArray = Encoding.UTF8.GetBytes(TextBox3.Text)
>
>         Dim ms As New MemoryStream
>         Dim cs As New CryptoStream(ms, des.CreateEncryptor(Key, IV),
> CryptoStreamMode.Write)
>         cs.Write(inputByteArray, 0, inputByteArray.Length)
>         cs.FlushFinalBlock()
>
>         TextBox4.Text = Convert.ToBase64String(ms.ToArray)

What did you try in the Pascal side (code please)? Did you decode the Base64 stream before passing the data to the decryption?

Regards,
Sven



--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus



--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to