Re: Same encryption codes cannot decrypt password from .NET 1.0 to 2.0



<hohans@xxxxxxxxx> wrote:
> I have an encryption class that encrypts and decrypts password using
> TripleDESCryptoServiceProvider. It was written originally in framework
> 1.0 and been working fine. And those passwords are stored in my SQL
> server.

<snip>

Looking at it to start with - you really shouldn't be assuming that the
bytes which come back from encryption are a valid Unicode string. I
would suggest base64 encoding/decoding to convert between byte arrays
and "normal" text. It's unrelated to the problem you're seeing (I
believe) but is something to watch out for.

It's also worth using a "using" statement to close streams, so they end
up being closed even if an exception occurs.

Finally, don't use Stream.Read without checking the return value -
there's no guarantee it will read everything you want it to. See
http://www.pobox.com/~skeet/csharp/readbinary.html for more details.
When you're using a MemoryStream, however, you can just call ToArray to
get the bytes.

I'll post an "improved" version of your code when I've modified the
current version. As I say, it won't solve the problem, but it should
make it more obvious that there *is* a problem unrelated to the above
:)

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Re: Two questions about passwords.
    ... properties where you have it registered using a SQL login. ... Yes, assuming there is no SSL encryption involved, SQL logins and passwords ... Jasper Smith (SQL Server MVP) ...
    (microsoft.public.sqlserver.security)
  • Re: how to change security settings
    ... "Specifies that the Windows password policies of the computer on which SQL ... Server is running should be enforced on this login." ... To be clear, I'm talking about the SQL passwords, not the Windows ...
    (microsoft.public.sqlserver.security)
  • sql6.5 login/pswd transfer to 2k
    ... to migrate all SQL Server 6.5 Logins and their Passwords ... Server 2000 server. ...
    (microsoft.public.sqlserver.server)
  • Re: SQL 7.0 to SQL 2000
    ... Transfer Logins and Passwords Between Instances of SQL Server ... > We currently have a production box running Windows NT server with SQL 7.0. ...
    (microsoft.public.sqlserver.setup)
  • Re: [SLE] Connecting Win98 to Samba
    ... > that I can't find the server from Win98, even though I can ping it it ... the password encryption setting. ... You DO NOT need plain text passwords. ...
    (SuSE)