Beispiel #1
0
        public string DecodeEncode(string word)
        {
            byte[] bytes = new byte[word.Length];

            for (int i = 0; i < word.Length; i++)
            {
                bytes[i] = (byte)(word[i] - 48);
            }

            string result = "";

            for (int i = 0; i < bytes.Length; i++)
            {
                byte resultByte = LFSR.XOR(bytes[i], LFSR.Shift());
                result += (char)(resultByte + 48);
            }

            return(result);
        }
        public string Encode(string word, string start, string polynomial)
        {
            byte[] bytes = new byte[word.Length];


            for (int i = 0; i < word.Length; i++)
            {
                bytes[i] = (byte)(word[i] - 48);
            }

            var    LSFR   = new LFSRService(start, polynomial);
            string result = "";

            foreach (var b in bytes)
            {
                byte resulByte = LSFR.Shift(b);
                result += (char)(resulByte + 48);
            }

            return(result);
        }