Salut tout le monde en C#4 la ligne
uEncoding.GetBytes(source)
ne compile plus, getbytes ne prend qu'un type string.
Comment je peux faire pour que cela fonctionne ?
Voici mon code complet
1 2 3 4 5 6 7 8 9 10 11 12 13
| public String CreateHash(SecureString source)
{
UnicodeEncoding uEncoding = new UnicodeEncoding();
//Stocke la chaine source dans un tableau d'octet
Byte[] octetsSource = uEncoding.GetBytes(source);
SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
//Création du Hash
Byte[] octetsHash = sha1.ComputeHash(octetsSource);
//Retourne une chaine encodé en base 64 qui est plus lisible
//qu'une chaine hashée
return Convert.ToBase64String(octetsHash);
} |
Partager