コード例 #1
0
 public void CreateShares()
 {
     string [] shares = _algorithm.Share(Phrase, Threshold, NumberOfShares);
     Shares.Clear();
     foreach (var sh in shares)
     {
         ShareName shareName = new ShareName(sh);
         Shares.Add(shareName);
     }
 }
コード例 #2
0
        public void ShareTest()
        {
            var    algorithm  = new TSSAlgorithm();
            string testString = "Hello world";

            string[] shares = algorithm.Share(testString, 3, 3);
            string   result = algorithm.Recover(new[] { shares[0], shares[1], shares[2] }).RecoveredText;

            Assert.AreEqual(testString, result);
        }
コード例 #3
0
        public void Recover_DuplicationsTest()
        {
            var    algorithm  = new TSSAlgorithm();
            string testString = "Hello world";

            string[] shares = algorithm.Share(testString, 2, 3);
            var      result = algorithm.Recover(new[] { shares[0], shares[0] });

            //If a share has at least 1 duplicate - return null
            Assert.IsNull(result);
        }
コード例 #4
0
        public void ShareTestWithLongInput()
        {
            var    algorithm  = new TSSAlgorithm();
            string testString = "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz" +
                                "abcdefghijklmnopqrstuvwxyz";

            string[] shares = algorithm.Share(testString, 3, 3);
            string   result = algorithm.Recover(new[] { shares[0], shares[1], shares[2] }).RecoveredText;

            Assert.AreEqual(testString, result);
        }