/// <summary> /// 构造函数 /// </summary> public DESAlgorithm() { // 初始化轮函数 RoundFunction = new DESRoundFunction( DESData.RawSBox.Select(array => new SubstitutionBox(array, 4)).ToArray(), new Permutator(DESData.EMatrix), new Permutator(DESData.PBox) ); // 初始化各种置换函数 KeyIP = new Permutator(DESData.InitialKeyPermutation); DataIP = new Permutator(DESData.InitialDataPermutation); SubKeyPC = new Permutator(DESData.SubKeyPC); DataIPRev = DataIP.GetInversePermutator(); // 初始化左移位数 ShiftArray = DESData.KeyShiftArray.Clone() as int[]; roundCount = ShiftArray.Length; }
/// <summary> /// 构造函数 /// </summary> /// <param name="roundS">输入的S盒</param> /// <param name="roundE">输入的E矩阵</param> /// <param name="roundP">输入的P盒</param> public DESRoundFunction(SubstitutionBox[] roundS, Permutator roundE, Permutator roundP) { S = roundS; EMatrix = roundE; PBox = roundP; }