[Mono-list] How can I md5 and crypt a string?

Sebastien Pouliot Sebastien Pouliot <spouliot@videotron.ca>
Tue, 24 Jun 2003 10:32:08 -0400


Ariel,

The cryptography in the .NET framework works using byte arrays.
For a similar result, you'll need to convert from string to byte array your
password, hash it, then reconvert the result into a string.

--- Sample ---

using System.Text;
using System.Security.Cryptography;

...

MD5 md = MD5.Create ();
byte[] digest = md.ComputeHash (Encoding.UTF8.GetBytes (password));
string result = Convert.ToBase64String (digest);

---

Sebastien Pouliot
Security Architect, Motus Technologies, http://www.motus.com/
work: spouliot@motus.com
home: spouliot@videotron.ca

----- Original Message -----
From: "Ariel Rios" <jrios@elektra.com.mx>
To: <mono-list@lists.ximian.com>
Sent: Monday, June 23, 2003 7:40 PM
Subject: [Mono-list] How can I md5 and crypt a string?


> In php I can check if a password is correct by doing something like:
> crypt($user_input,$this->getPassword())
>
> Also I can do
> $hash = md5 ($str);
>
> Is there a way to do so currently in mono?
> --
> Ariel Rios <ariel@gnu.org>
> --
> Ariel Rios <jrios@elektra.com.mx>
> Elektra - Gerencia GNU
>
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>