HighTechTalks DotNet Forums  

Encryption / Decryption problem

Dotnet Security microsoft.public.dotnet.security


Discuss Encryption / Decryption problem in the Dotnet Security forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
OleD
 
Posts: n/a

Default Encryption / Decryption problem - 09-20-2007 , 08:46 AM






Hello!

When I decrypt my messages there is almost always some text missing at
the end. Also very short messages get decrypted to empty strings.


Example code in Delphi.net
-----

function TWebservice1.EncryptValue(Value: string): ByteArray;
var
Cipher : RijndaelManaged;
transform : ICryptoTransform;
begin
try
Cipher := RijndaelManaged.Create;
Cipher.KeySize := 256;

Cipher.key := convert.FromBase64String(LogoKrypteringsStreng);
Cipher.IV := Convert.FromBase64String(LogoKrypteringsVektor);
Cipher.Padding := PaddingMode.PKCS7;
transform := cipher.CreateEncryptor;
result :=
transform.TransformFinalBlock(Encoding.Unicode.Get Bytes(Value),
0,value.Length);
except
on e : Exception do begin
SkrivLog(e.Message);
raise;
end;
end;
end;

function TWebservice1.DecryptValue(KrypteretValue: ByteArray): string;
var
Cipher : RijndaelManaged;
transform : ICryptoTransform;
begin
try
Cipher := RijndaelManaged.Create;
Cipher.KeySize := 256;

Cipher.key := convert.FromBase64String(LogoKrypteringsStreng);
Cipher.IV := convert.FromBase64String(LogoKrypteringsVektor);
Cipher.Padding := PaddingMode.PKCS7;
transform := cipher.CreateDecryptor;
result :=
Encoding.Unicode.GetString(transform.TransformFina lBlock(KrypteretValue,
0,Length(KrypteretValue)));
except
on e : Exception do begin
SkrivLog(e.Message);
raise;
end;
end;
end;


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.