Ejemplo n.º 1
0
        protected override BitArray Calculate(int dataIndex, BitArray op)
        {
            PSData sBox = Parser.PermuteSBoxStorage.SBox[dataIndex];
            // 将op转为十进制
            int opInt     = Convert.ToInt32(BlockCipherUtil.BitArrayToString(op), 2);
            int resultInt = sBox.Data[opInt];
            // 将temp转为二进制字符串
            StringBuilder resultStr = new StringBuilder(Convert.ToString(resultInt, 2));

            for (int i = resultStr.Length; i < sBox.OutputLength; i++)
            {
                resultStr.Insert(0, "0");
            }
            BitArray result = BlockCipherUtil.StringToBitArray(resultStr.ToString());

            return(result);
        }
Ejemplo n.º 2
0
 public override BitArray Handle(string expression)
 {
     return(BlockCipherUtil.ConstToBitArray(expression));
 }
Ejemplo n.º 3
0
 public string GetKey()
 {
     return(BlockCipherUtil.BitArrayToString(VariableStorage["key"]));
 }
Ejemplo n.º 4
0
 public string GetState()
 {
     return(BlockCipherUtil.BitArrayToString(VariableStorage["state"]));
 }
        /// <summary>
        /// 添加一个变量,以字符串作为初始变量
        /// 默认覆盖
        /// </summary>
        public void AddVariable(string key, string value, bool overlay = true)
        {
            BitArray temp = BlockCipherUtil.StringToBitArray(value);

            AddVariable(key, temp, overlay);
        }