コード例 #1
0
        public void Encrypt_Hello_World_and_Decrypt_with_Password()
        {
            const string str           = "Hello World!";
            const string pass          = "******";
            var          encrypted_str = _Encryptor.Encrypt(str, pass);
            var          decrypted_str = _Encryptor.Decrypt(encrypted_str, pass);

            Assert.AreNotEqual(str, encrypted_str);
            Assert.AreEqual(str, decrypted_str);
        }
コード例 #2
0
        public void Encrypt_Text_And_Decrypt_With_Password()
        {
            const string STR      = "Text";
            const string PASSWORD = "******";

            var encryptedStr = _encryptor.Encrypt(STR, PASSWORD);
            var decryptedStr = _encryptor.Decrypt(encryptedStr, PASSWORD);

            Assert.AreNotEqual(STR, encryptedStr);
            Assert.AreEqual(STR, decryptedStr);
        }
コード例 #3
0
        public void Encrypt_Hello_World_and_Decrypt_with_Password()
        {
            const string str           = "Hello World!";
            const string password      = "******";
            var          encrypted_str = _Encryptor.Encrypt(str, password);
            var          decrypted_str = _Encryptor.Decrypt(encrypted_str, password);

            //var wrong_pass_decrypted = _Encryptor.Decrypt(encrypted_str, "QWE");

            Assert.AreNotEqual(str, encrypted_str);
            Assert.AreEqual(str, decrypted_str);
            //Assert.AreNotEqual(str, wrong_pass_decrypted);
        }
コード例 #4
0
ファイル: AccountController.cs プロジェクト: LimondD/Quest
        public IActionResult CreateUser(UserDto user)
        {
            _db.Users.Add(new UserEntity
            {
                Id          = Guid.NewGuid(),
                BirthDate   = user.BirthDate,
                Email       = user.Email,
                LastName    = user.LastName,
                Name        = user.Name,
                Password    = _encryptorService.Encrypt(user.Password),
                Patronymic  = user.Patronymic,
                CreatedDate = DateTime.Now,
                EditedDate  = DateTime.Now,
                IsDeleted   = false
            });
            _db.SaveChanges();

            return(Ok());
        }
コード例 #5
0
        public void Load()
        {
            Debug.WriteLine("Вызвана процедура загрузки данных.");

            if (Servers is null || Servers.Count == 0)
            {
                Servers = Enumerable.Range(1, 5)
                          .Select(i => new Server
                {
                    Id       = i,
                    Name     = $"Имя {i}",
                    Address  = $"smtp.server{i}",
                    Login    = $"Пользователь {i}",
                    Password = _EncryptorService.Encrypt($"Пароль{i}", "Пароль!"),
                    UseSSL   = i % 2 == 0
                })
                          .ToList();
            }

            if (Senders is null || Senders.Count == 0)
            {
                Senders = Enumerable.Range(1, 20)
                          .Select(i => new Sender
                {
                    Id      = i,
                    Name    = $"Отправитель {i}",
                    Address = $"sender_{i}@server.ru",
                })
                          .ToList();
            }

            if (Recipients is null || Recipients.Count == 0)
            {
                Recipients = Enumerable.Range(1, 20)
                             .Select(i => new Recipient
                {
                    Id      = i,
                    Name    = $"Получатель {i}",
                    Address = $"recipient_{i}@server.ru",
                })
                             .ToList();
            }

            if (Mails is null || Mails.Count == 0)
            {
                Mails = Enumerable.Range(1, 20)
                        .Select(i => new Mail
                {
                    Id      = i,
                    Subject = $"Заголовок {i}",
                    Body    = $"Текст сообщения {i}."
                })
                        .ToList();
            }
        }
コード例 #6
0
        private string GenerateTokenByEmail(string login, string userId)
        {
            var guid = Guid.NewGuid();
            var date = DateTime.UtcNow;

            var tokenString = BuildTokenString(guid, login, userId, date);
            var encrypted   = _iEncryptorService.Encrypt(tokenString);

            SaveToken(guid, login, userId, date);

            return(encrypted);
        }