Re: Crypto API using RC2 instead of RC4?

From: Valery Pryamikov (valery_at_harper.no)
Date: 11/24/05


Date: Thu, 24 Nov 2005 10:01:17 +0100


"prepare data for decryption" step is only pre-allocating buffers. btw.
decryption doesn't expand, so you don't need to increase buffer size for
decryption, and even for encryption - doubling of buffer size is quite
redundant - you only need to add whole block size and round it up to the
nearest number divisable by 8 (as usually -- code in KB article is only for
demostration purposes and not for use in production).
padding is added by cryptencrypt and removed by cryptdecrypt. Since you
didn't specify padding -- you use default PKCS7 padding.
What could be a problem is your use of strings as storage of encrypted data.
Encrypted data is binary array. No, don't send me your code -- I don't
program vb, I don't have vb6 installed anywhere around and I even don't have
any time to look at your code, sorry.

-Valery.
http://www.harper.no/valery

"Matt" <mtaylor@gladstonemrm.com> wrote in message
news:1132788420.573740.144320@g49g2000cwa.googlegroups.com...
> Hello Valery,
>
> My test application creates a random string.
> It then passses that string to be encrypted.
> The returned encrypted string is then immediately decrypted to make
> sure it matches the original string.
> This works about 19 out of 20 times until the CryptDecrypt API call
> returns False resulting in an error being raised.
>
> I'm not clued up on encryption but as far as I can tell all the padding
> is done in the
> '-- Prepare data for decryption.--' section in the function I posted,
> and that is identical to the Encrypt function so should work fine?
> The KB example code certainly does not provide the ability to set any
> padding, only the ciphers and a password key.
>
> If you are willing I am happy to send you a ready to run test project
> so that you can see for yourself.
>
> Thanks,
>
> Matt
>



Relevant Pages

  • Length of the data to decrypt is invalid
    ... I found this code on a site for doing string encryption/decryption. ... // Create a symmetric algorithm. ... // This is done to make encryption more secure. ... // This will tell it that we have done our decryption ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: cryptography
    ... The Rijndael class is intended to be the ... > For a couple examples of simple encryption using the RijndaelManaged class ... >> internal static void Encrypt(string StringToCrypt, string fileOut, string ... >> when i run the above code, encryption is smooth,however when decryption ...
    (microsoft.public.dotnet.languages.csharp)
  • PHP mcrypt and VB.NET cryptoservice interop
    ... I am consuming a PHP-based web service over VB.NET but having some problems with encryption. ... but for some reason - the characters in positions 3-6 of the total length of 64 are different compared to original string at PHP side. ... The decryption code follows: ... Dim encryptedStream As MemoryStream = New MemoryStream ...
    (microsoft.public.dotnet.security)
  • Re: Securing data to a process principal
    ... encryption key first time for the user - and use it later). ... secret. ... I need the decryption to ... You MAY think that instead of a filter driver you can simply ...
    (microsoft.public.platformsdk.security)
  • RE: Bad Data using TripleDES Encryption
    ... // first we need to translate the string into an array of bytes ... // chain two crypto stream together - encrypting and base64 encoding ... // set the decryption key and IV ... Bad Data using TripleDES Encryption ...
    (microsoft.public.dotnet.framework.aspnet.security)