Exemplo n.º 1
0
        /// <summary>
        /// Encrypt a Newhl User
        /// </summary>
        /// <param name="user">The current user</param>
        /// <returns>An encrypted string</returns>
        public string Encrypt(Newhl.Common.DomainModel.User user)
        {
            string retVal = string.Empty;

            if (user != null)
            {
                AESManager encryptor = new AESManager(this.EncryptionKey, this.Salt);
                retVal = encryptor.Encrypt(Newhl.Common.Utilities.SerializationUtilities.SerializeObjectToXmlString(user));
            }

            return(retVal);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Decrypt to a Newhl User
        /// </summary>
        /// <param name="encryptedString">The encrypted string</param>
        /// <returns>A Newhl user instance</returns>
        public Newhl.Common.DomainModel.User Decrypt(string encryptedString)
        {
            Newhl.Common.DomainModel.User retVal = null;

            if (!string.IsNullOrEmpty(encryptedString))
            {
                AESManager encryptor      = new AESManager(this.EncryptionKey, this.Salt);
                string     decryptedValue = encryptor.Decrypt(encryptedString);
                retVal = Newhl.Common.Utilities.SerializationUtilities.DeserializeXmlToObject <Newhl.Common.DomainModel.User>(decryptedValue);
            }

            return(retVal);
        }