Как зашифровать Расшифровать пароль в. net core 2.1 - PullRequest
0 голосов
/ 17 апреля 2020

Я столкнулся с проблемой пароля. Я хочу сохранить SaltKey, SaltKeyIV и пароль в БД, используя функцию преобразования в строку.

static void Main(string[] args)
            {
                try
                {
                    string Password = "Chandan";
                    string encryptPassword = string.Empty;
                    string salt_key = string.Empty;
                    string salt_key_iv = string.Empty;
                    EncryptHelperObj _objuserEncryptHelperObj = new EncryptHelperObj();
                    if (Password.Trim() != "")
                    {
                        _objuserEncryptHelperObj = EncryptHelper.Get_EncryptedPassword(_objuserEncryptHelperObj, Password);
                        Password = _objuserEncryptHelperObj.Value;
                        salt_key = _objuserEncryptHelperObj.SaltKey;
                        salt_key_iv = _objuserEncryptHelperObj.SaltKeyIV;
                    }

                    EncryptHelperObj _objuserEncryptHelperObj1 = new EncryptHelperObj();

                    _objuserEncryptHelperObj.SaltKey = salt_key;
                    _objuserEncryptHelperObj.SaltKeyIV = salt_key_iv;

                    string DecryptedPassword = EncryptHelper.Get_DecryptedPassword(_objuserEncryptHelperObj, Password);
                }
                catch (Exception ex)
                {

                }
            }
        }

public static EncryptHelperObj Encrypt_NewHelper()
    {[enter image description here][1]
        EncryptHelperObj _EncryptHelperObj = new EncryptHelperObj();
        Aes myAes = Aes.Create();
        _EncryptHelperObj.SaltKey = Encoding.Default.GetString(myAes.Key);
        _EncryptHelperObj.SaltKeyIV = Encoding.Default.GetString(myAes.IV);
        return _EncryptHelp[enter image description here][1]erObj;
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...