public string Encrypt(string input)
        {
            var output = Convert.ToBase64String(
                _cryptographyService.ComputeHash(input));

            return(HttpUtility.UrlEncode(output));
        }
        public string Encrypt(string input)
        {
            var output = _cryptographyService.ComputeHash(input)
                         .Select(x => x.ToString("x2"))
                         .ToList();

            return(string.Join("", output));
        }
Esempio n. 3
0
 public bool Login(string email, string password)
 {
     try
     {
         var passwordHash = _cryptographyService.ComputeHash(password);
         var customer     = _customerRepository.GetSingle(x => x.Email == email && x.Password == passwordHash);
         if (customer == null)
         {
             return(false);
         }
         return(true);
     }
     catch (Exception ex) { return(false); }
 }
Esempio n. 4
0
        public async Task <ServiceResult> AddUser(UserDto userModel)
        {
            userModel.Id = await _userRepository.AddAsyncById(new User {
                Email     = userModel.Email,
                FirstName = userModel.FirstName,
                LastName  = userModel.LastName,
                Password  = _cryptographyService.ComputeHash(userModel.Password)
            });

            await _userRoleRepository.AddAsync(new UserRole()
            {
                RoleId = (int)userModel.Role, UserId = userModel.Id
            });

            return(new ServiceResult(ServiceResultStatus.Success, null, _localizer.Localize("New user created successfully.")));
        }
Esempio n. 5
0
        public Customer CreateCustomer(Customer customer)
        {
            try
            {
                string passwordHash = _cryptographyService.ComputeHash(customer.Password);
                customer.Password    = passwordHash;
                customer.Id          = Guid.NewGuid();
                customer.IsActive    = true;
                customer.CreatedDate = DateTime.Now;

                var result = _customerRepository.Add(customer);
                if (result == (int)GlobalConfig.Result.SUCCESS)
                {
                    return(customer);
                }
                return(null);
            }
            catch (Exception ex) { throw ex; }
        }
Esempio n. 6
0
 private string getHashed(string password)
 {
     return(_cryptographyService.ComputeHash(password));
 }