Exemplo n.º 1
0
        public void TestToString()
        {
            var testSubject = new CipherText
            {
                adata  = "atada",
                cipher = "rehpic",
                ct     = "tc",
                iter   = 1000,
                iv     = "vi",
                ks     = 1000,
                mode   = "edom",
                v      = 1,
                salt   = "tlas",
                ts     = 1
            };
            var testResult = testSubject.ToString();

            Assert.IsNotNull(testResult);
            Assert.IsFalse(String.IsNullOrWhiteSpace(testResult));

            Assert.IsTrue(testResult.Contains(string.Format("\"adata\":\"{0}\"", testSubject.adata)));
            Assert.IsTrue(testResult.Contains(string.Format("\"cipher\":\"{0}\"", testSubject.cipher)));
            Assert.IsTrue(testResult.Contains(string.Format("\"ct\":\"{0}\"", testSubject.ct)));
            Assert.IsTrue(testResult.Contains(string.Format("\"iter\":{0}", testSubject.iter)));
            Assert.IsTrue(testResult.Contains(string.Format("\"iv\":\"{0}\"", testSubject.iv)));
            Assert.IsTrue(testResult.Contains(string.Format("\"ks\":{0}", testSubject.ks)));
            Assert.IsTrue(testResult.Contains(string.Format("\"mode\":\"{0}\"", testSubject.mode)));
            Assert.IsTrue(testResult.Contains(string.Format("\"v\":{0}", testSubject.v)));
            Assert.IsTrue(testResult.Contains(string.Format("\"salt\":\"{0}\"", testSubject.salt)));
            Assert.IsTrue(testResult.Contains(string.Format("\"ts\":{0}", testSubject.ts)));
        }
Exemplo n.º 2
0
        /*
         * /// <summary>
         * ///   The cpr test.
         * /// </summary>
         * [Test] public void CPRTest() {
         * var cpr = new CPR(2312881133);
         * Assert.That(cpr.Value == 2312881133);
         * Assert.That(cpr.ToString().Equals("2312881133"));
         * Assert.That(2312881133.Equals(cpr));
         * }
         */
        /// <summary>
        ///   The cipher text test.
        /// </summary>
        [Test] public void CipherTextTest()
        {
            var bytes  = new byte[] { 1, 2, 3, 4, 5, 6 };
            var cipher = new CipherText(bytes);

            Assert.That(bytes.IsIdenticalTo(cipher));
            Assert.That(bytes.IsIdenticalTo(cipher.Value));
            Assert.That(cipher.ToString() != null);
        }
Exemplo n.º 3
0
        public static string ToPlainText(CipherText encryptedData, string bulkCipherKey)
        {
            //js and C# string escape seq's are the same...
            var results =
                Resources.ScriptEngine.Evaluate(string.Format("sjcl.decrypt(\"{0}\", \"{1}\" )",
                                                              bulkCipherKey,
                                                              encryptedData.ToString().Replace("\"", "\\\"")));

            return(results.ToString());
        }
Exemplo n.º 4
0
        public void ToggleStringJson()
        {
            var testValues = new CipherText
            {
                adata  = "atada",
                cipher = "rehpic",
                ct     = "tc",
                iter   = 1000,
                iv     = "vi",
                ks     = 1000,
                mode   = "edom",
                v      = 1,
                salt   = "tlas",
                ts     = 1
            };
            CipherText testSubject;
            var        testResultTryParse = CipherText.TryParse(testValues.ToString(), out testSubject);

            Assert.IsTrue(testResultTryParse);
        }