E
E
enwr2020-11-06 15:15:43
C++ / C#
enwr, 2020-11-06 15:15:43

How to fix password decryption error?

I am writing a c# program that displays data (logins, passwords, etc.) to the user in browsers, and the problem is that an exception appears at the decryption stage: System.Security.Cryptography.CryptographicException: "The parameter is set incorrectly."
I can't fix it, here's that part of the code

public static string Decrypt(string EncryptedData)
{
    if (EncryptedData == null || EncryptedData.Length == 0)
    {
        return null;
    }
    byte[] bytes = ProtectedData.Unprotect(Encoding.Default.GetBytes(EncryptedData),null,DataProtectionScope.CurrentUser);//ошибка тут

    return Encoding.UTF8.GetString(bytes);
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2020-11-06
@enwr

Error somewhere in

ProtectedData.Unprotect(Encoding.Default.GetBytes(EncryptedData),null,DataProtectionScope.CurrentUser)

See the stack trace, documentation, and sources - there are no telepaths here, and it won't work without them if you don't attach more code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question