예제 #1
0
        //Расширение блоков R с 4 до 6 бит
        private string r4to6(string bitStr)
        {
            string[]      formattedBitStr = Utills.BinaryFormat(bitStr, 4).Split(' ');
            StringBuilder extendedBitStr;
            StringBuilder result = new StringBuilder(48);

            for (int i = 0; i < formattedBitStr.Length; i++)
            {
                extendedBitStr = new StringBuilder(6);

                extendedBitStr.Append(formattedBitStr[(i - 1 + 8) % 8].ElementAt(3));
                extendedBitStr.Append(formattedBitStr[i]);
                extendedBitStr.Append(formattedBitStr[(i + 1 + 8) % 8].ElementAt(0));

                result.Append(extendedBitStr);
            }

            return(result.ToString());
        }
예제 #2
0
파일: Gost.cs 프로젝트: koidula/kmisoib-kr
        private void Init()
        {
            var r0_str = message.Substring(message.Length / 2, message.Length / 2);

            r0 = Utills.StickedBinaryMsg(r0_str);

            var x0_str = key;

            x0 = Utills.StickedBinaryMsg(x0_str);

            fR0X0 = Utills.Modulo2Pow32(r0, x0);

            filled = SubstituteElements(fR0X0);

            shifted = Utills.Shift(filled, -11);

            var l0_str = message.Substring(0, message.Length / 2);

            l0 = Utills.StickedBinaryMsg(l0_str);

            r1 = Utills.Modulo2(l0, shifted);
        }