Do you have access to the encryption methods used to generate the password?
c# decrypt sha1
Ali Yılmaz
81
Reputation points
Hi,
I am struggling to decrypt users in my nopcommerce project. But when I try to solve it, I get an error. What is the reason for this error? How can i solve it.
Password : 41F954431E47BAF510C98037E7D402979D1BF318
public virtual string DecryptText(string cipherText, string encryptionPrivateKey = "")
{
if (String.IsNullOrEmpty(cipherText))
return cipherText;
if (String.IsNullOrEmpty(encryptionPrivateKey))
encryptionPrivateKey = "8346958881167965";
var tDESalg = new TripleDESCryptoServiceProvider();
tDESalg.Key = Encoding.ASCII.GetBytes(encryptionPrivateKey.Substring(0, 16));
tDESalg.IV = Encoding.ASCII.GetBytes(encryptionPrivateKey.Substring(8, 8));
byte[] buffer = Convert.FromBase64String(cipherText);
return DecryptTextFromMemory(buffer, tDESalg.Key, tDESalg.IV);
}
private string DecryptTextFromMemory(byte[] data, byte[] key, byte[] iv)
{
using (var ms = new MemoryStream(data))
{
using (var cs = new CryptoStream(ms, new TripleDESCryptoServiceProvider().CreateDecryptor(key, iv), CryptoStreamMode.Read))
{
using (var sr = new StreamReader(cs, Encoding.Unicode))
{
return sr.ReadLine();
}
}
}
}
2 answers
Sort by: Most helpful
-
-
Ali Yılmaz 81 Reputation points
2021-09-15T11:15:16.79+00:00 Yes i have access to everything. This code is nopcommerce own code.
But I get error "The length of the data to be decrypted is invalid"
I have stated above, I need to decrypt the user passwords in the database.