Beispiel #1
0
        public void TestEncrypt()
        {
            RSA      rsa       = RSA.Create();
            ICrypter crypter   = new RSAPasswordCrypter(rsa);
            string   encrypted = crypter.EncryptString("testmessage");

            Assert.AreEqual(256, encrypted.Length);
        }
Beispiel #2
0
        public void TestDecrypt()
        {
            RSA      rsa       = RSA.Create();
            ICrypter crypter   = new RSAPasswordCrypter(rsa);
            string   encrypted = crypter.EncryptString("testmessage");
            string   decrypted = crypter.DecryptString(encrypted);

            Assert.AreEqual("testmessage", decrypted);
        }
Beispiel #3
0
        public void FixtureSetup()
        {
            settingsMySql = new Hashtable();
            settingsMySql.Add("vendor", DatabaseConfig.MySql);
            settingsMySql.Add("server", "b");
            settingsMySql.Add("database", "c");
            settingsMySql.Add("username", "d");
            settingsMySql.Add("password", "e");
            settingsMySql.Add("port", "f");

            rsa               = RSA.Create();
            crypter           = new RSAPasswordCrypter(rsa);
            password          = "******";
            encryptedPassword = crypter.EncryptString(password);
        }
Beispiel #4
0
        private string TryGetPasswordFrom(NameValueCollection appSettings)
        {
            var password = appSettings["password"];

            if (string.IsNullOrEmpty(password))
            {
                return("admin");
            }
            var rsa = RSA.Create();
            //rsa.FromXmlString(Resources.PrivateKey);  TODO: this would need a new private key if Splunk is posted to
            var rsaPasswordCrypter = new RSAPasswordCrypter(rsa);

            password = rsaPasswordCrypter.DecryptString(password);
            return(password);
        }