J'ai une base de données SQL stockant des mots de passe cryptés via une application .NET, que j'ai besoin de décrypter via une application ColdFusion. Je n'arrive tout simplement pas à faire avancer les choses pour que le décryptage des FC fonctionne. Toute aide serait appréciée. Merci.Aide au décryptage des mots de passe ColdFusion créés dans .NET
Le code de décryptage .NET est:
public string Decrypt(string input)
{
try
{
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
int ZeroBasedByteCount = (input.Length/2);
//Put the input string into the byte array
byte[] inputByteArray = new byte[ZeroBasedByteCount];
int i;
int x;
for (x = 0;x<ZeroBasedByteCount;x++)
{
i = (Convert.ToInt32(input.Substring(x * 2, 2), 16));
inputByteArray[x] = (byte)i;
}
//Create the crypto objects
des.Key = ASCIIEncoding.ASCII.GetBytes(key);
des.IV = ASCIIEncoding.ASCII.GetBytes(key);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write);
//Flush the data through the crypto stream into the memory stream
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
//Get the decrypted data back from the memory stream
StringBuilder ret = new StringBuilder();
foreach(byte b in ms.ToArray())
{
ret.Append((char)b);
}
return ret.ToString();
}
catch(Exception ex)
{
throw(ex);
return null;
}
}
D'où vient la variable clé? –
Bien que cela ne résout pas ce problème spécifique, vous ne devriez pas avoir à déchiffrer les mots de passe de toute façon - ils doivent toujours utiliser un hachage unidirectionnel, et vérifier les tentatives de cryptage et comparer les deux valeurs cryptées. –
@Peter Boughton: Amen à cela. – Tomalak