コード例 #1
0
ファイル: RavenDB_1824.cs プロジェクト: j2jensen/ravendb
 private string ComputeHashUsingMD5(params string[] blocks)
 {
     using (var hash = new DefaultEncryptor().CreateHash())
     {
         return ComputeHash(hash, blocks);
     }
 }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: RavenDB_1824.cs プロジェクト: xinix00/ravendb
 private string ComputeHashUsingMD5(params string[] blocks)
 {
     using (var hash = new DefaultEncryptor().CreateHash())
     {
         return(ComputeHash(hash, blocks));
     }
 }
コード例 #4
0
        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"));
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #8
0
ファイル: Encryptor.cs プロジェクト: WimVergouwe/ravendb
		static Encryptor()
		{
			Current = new DefaultEncryptor();
		}