Ejemplo n.º 1
0
        public string GetUserEmail(string userId)
        {
            var user = _piiContext.AspNetUsers.SingleOrDefault(u => u.Id == userId);

            if (user == null)
            {
                return(null);
            }

            return(_symmetricEncryptor.DecryptString(user.Email, KEYNAME_EMAIL));
        }
Ejemplo n.º 2
0
        public IActionResult Encrypt(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                value = "password";
            }

            var values = new List <string>();

            var encrypted = _encryptor.EncryptString(value, "AspNetUsers_UserName");
            var decrypted = _encryptor.DecryptString(encrypted, "AspNetUsers_UserName");

            values.Add(encrypted);
            values.Add(decrypted);

            return(View(values));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Hex Format으로 암호화된 문자열을 복호화하여 원래 문자열로 반환한다.
        /// </summary>
        /// <param name="cipherText">Hex Format으로 암호화된 문자열</param>
        /// <returns>Plain Text</returns>
        public string Decrypt(string cipherText)
        {
            if (IsDebugEnabled)
            {
                log.Debug("암호화된 문장을 복원합니다...");
            }

            if (cipherText.IsEmpty())
            {
                return(null);
            }

            return(Encryptor.DecryptString(cipherText, EncryptionStringFormat.HexDecimal));

            //var plainBytes = Encryptor.Decrypt(cipherText.StringToBytes(EncryptionStringFormat.HexDecimal));

            //return Encoding.Unicode.GetString(plainBytes).TrimEnd('\0');
        }