Пример #1
0
        static void Main(string[] args)
        {
            var key          = "Klucz";
            var textToCypher = "Lampka".ToUpperInvariant();

            PolybiusMatrixGenerator matrixGenerator = new PolybiusMatrixGenerator(key.UnifyKey());

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    Console.Write(matrixGenerator.PobliusMatrix[i, j] + " ");
                }
                Console.WriteLine();
            }

            DelastelleCypherDownToUp crypter = new DelastelleCypherDownToUp(matrixGenerator);
            var encodedText = crypter.Encode(textToCypher);

            Console.WriteLine(encodedText);
            var decodedText = crypter.Decode(encodedText);

            Console.WriteLine(decodedText);
            //var encodedText = crypter.GetEncodedText(textToCypher, DelastelleCypherType.Horizontal);
            //Console.WriteLine($"Szyfr: {encodedText}");
            //Console.WriteLine($"Po deszyfracji: {crypter.DecodeText(encodedText, DelastelleCypherType.Horizontal)}");
            Console.ReadKey();
        }
Пример #2
0
        public static ICypher Create(string key, DelastelleCypherType type)
        {
            PolybiusMatrixGenerator matrixGenerator = new PolybiusMatrixGenerator(key);

            switch (type)
            {
            case DelastelleCypherType.Horizontal:
                return(new DelastelleCypherHorizontal(matrixGenerator));

            case DelastelleCypherType.DownToUp:
                return(new DelastelleCypherDownToUp(matrixGenerator));

            case DelastelleCypherType.UpToDown:
                return(new DelastelleCypherUpToDown(matrixGenerator));
            }

            throw new Exception("Type doesn't exist");
        }
 protected DelastelleCypher(PolybiusMatrixGenerator matrixGenerator)
 {
     MatrixGenerator = matrixGenerator;
     Matrix          = MatrixGenerator.PobliusMatrix;
 }
 public DelastelleCypherUpToDown(PolybiusMatrixGenerator matrixGenerator) : base(matrixGenerator)
 {
 }
Пример #5
0
 public DelastelleCypherHorizontal(PolybiusMatrixGenerator matrixGenerator) : base(matrixGenerator)
 {
 }
 public DelastelleCypherDownToUp(PolybiusMatrixGenerator matrixGenerator) : base(matrixGenerator)
 {
 }