private string ComputeHashUsingMD5(params string[] blocks) { using (var hash = new DefaultEncryptor().CreateHash()) { return ComputeHash(hash, blocks); } }
public IEncryptionService Create(IProcessExecutionContext executionContext, bool disableCache = false) { bool useCache = !disableCache && executionContext.Cache != null; if (useCache && executionContext.Cache.Exists(CACHE_KEY)) { return(executionContext.Cache.Get <IEncryptionService>(CACHE_KEY)); } var settings = SettingsFactory.Create(executionContext); var secretProvider = SecretProviderFactory.Create(executionContext, disableCache); var encryptionKey = secretProvider.GetValue <string>(settings.EncryptionKeyName) ?? throw new Exception("Missing Secret for encryption key."); var encryptor = new DefaultEncryptor(encryptionKey); var cacheTimeout = settings.CacheTimeout; if (useCache && cacheTimeout.HasValue) { executionContext.Cache.Add <IEncryptionService>(CACHE_KEY, encryptor, cacheTimeout.Value); } return(encryptor); }
private string ComputeHashUsingMD5(params string[] blocks) { using (var hash = new DefaultEncryptor().CreateHash()) { return(ComputeHash(hash, blocks)); } }
private static void CreateDatabaseSchemaAndDemoData() { CreateDatabaseSchema(); var session = NHibernateHelper.SessionFactory.OpenSession(); var passwordPolicy = new RegularExpressionPasswordPolicy(".{5,}$"); var translationsRepository = new TranslationRepository(session, new InMemoryKeyValueCache()); var applicationSettings = new ApplicationSettings(); var encryptor = new DefaultEncryptor(); var userRepository = new UserRepository(session, passwordPolicy, applicationSettings, encryptor); // Create administrators PocoGenerator.CreateAdministrators(userRepository); // Create users PocoGenerator.CreateUsers(100, userRepository); session.Transaction.Begin(); // Create translations PocoGenerator.CreateTranslations(translationsRepository); session.Transaction.Commit(); // Create logitems PocoGenerator.CreateLogItems(new NLogLogger(applicationSettings, "Console.Admin")); }
public void CanCreateSha512EncryptedString() { const string testString = "String to be encrypted"; var encryptedString = new DefaultEncryptor().Sha512Encrypt(testString); Assert.AreEqual(128, encryptedString.Count()); Assert.AreEqual("d8022b70792f76ed94c007962dc6fcbcb15463ab79eedbaaa0c42293918252e9c73c6ea121a19238adcae68f24c71e971346b806e5ead70a61caaa3a13a8b62a", encryptedString); }
public void CanCreateMd5EncryptedString() { const string testString = "String to be encrypted"; var encryptedString = new DefaultEncryptor().Md5Encrypt(testString); Assert.AreEqual(32, encryptedString.Count()); Assert.AreEqual("52a3800d865b9017ac36e4d036133a91", encryptedString); }
public IEncryptionService Create(IProcessExecutionContext executionContext, bool disableCache = false) { bool useCache = !disableCache && executionContext.Cache != null; if (useCache && executionContext.Cache.Exists(CACHE_KEY)) { return(executionContext.Cache.Get <IEncryptionService>(CACHE_KEY)); } var settings = SettingsFactory.Create(executionContext); var encryptor = new DefaultEncryptor(); var cacheTimeout = settings.CacheTimeout; if (useCache && cacheTimeout.HasValue) { executionContext.Cache.Add <IEncryptionService>(CACHE_KEY, encryptor, cacheTimeout.Value); } return(encryptor); }
static Encryptor() { Current = new DefaultEncryptor(); }