public void EncryptTest() { var target = new RijndaelCryptoProvider() { Key = Key, InitalizationVector = InitializationVector }; var clearText = "Test"; var expected = new byte[] { 92, 88, 212, 96, 182, 215, 173, 130, 236, 184, 241, 111, 218, 2, 147, 142 }; var actual = target.Encrypt(clearText); Assert.AreEqual(System.Convert.ToBase64String(expected), System.Convert.ToBase64String(actual)); }
/*public SimpleAuthenticationTicket(string Token) { //Пока используем Forms cryptoProvider = new RijndaelCryptoProvider(SettingsManager.AuthenticationSettings.EncryptionKey); if (string.IsNullOrWhiteSpace(Token)) { return; } if (ticket == null) { return; } IssueDate = ticket.IssueDate; ExpirationDate = ticket.Expiration; UserName = ticket.Name; KeepLoggedIn = ticket.IsPersistent; }*/ public string Encrypt() { /*string userData = string.Format("UserId={0};DisplayName={1}", User.UserIdentity.UserId, User.UserIdentity.DisplayName);*/ ICryptoProvider provider = new RijndaelCryptoProvider(SettingsManager.AuthenticationSettings.EncryptionKey); return provider.Encrypt(this); /*FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, UserName, IssueDate, ExpirationDate, KeepLoggedIn, ""); return FormsAuthentication.Encrypt(ticket);*/ }