public void Get16SubKeysFromKey() { BitArray permutatedKey = Permutations.Permute(Data.Permutation56Table, Key); DesHelper.DivideToTwoArrays(permutatedKey, out BitArray leftPermutatedKey, out BitArray rightPermutatedKey); List <BitArray> leftShitedKeys = new List <BitArray>(16); List <BitArray> rightShitedKeys = new List <BitArray>(16); leftShitedKeys.Add(DesHelper.ShiftLeft(leftPermutatedKey)); rightShitedKeys.Add(DesHelper.ShiftLeft(rightPermutatedKey)); for (int i = 0; i < 15; i++) { leftShitedKeys.Add(DesHelper.ShiftLeft(leftShitedKeys[i])); rightShitedKeys.Add(DesHelper.ShiftLeft(rightShitedKeys[i])); } List <BitArray> shiftedSubKeys = new List <BitArray>(16); for (int i = 0; i < 16; i++) { DesHelper.ConnectTwoArraysIntoOne(leftShitedKeys[i], rightShitedKeys[i], out BitArray connected); shiftedSubKeys.Add(connected); SubKeys.Add(Permutations.Permute(Data.Permutation48Table, shiftedSubKeys[i])); } }
// keyPath (path to key), dive (recursively go through SubKeys) public RegLookupParse(string keyPath, bool dive = true) { RegistryKey localKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); localKey = localKey.OpenSubKey(keyPath, false); // Check for empty (non-exsistent) key if (localKey == null) { Error = true; return; } // Process any Sub Keys foreach (string subKeyName in localKey.GetSubKeyNames()) { string subKeyPath = keyPath + @"\" + subKeyName; // Check if it's needed to go through the subkeys if (dive) { SubKeys.Add(new SubKey { KeyPath = subKeyPath, SubKeyObj = new RegLookupParse(subKeyPath) }); } else { SubKeys.Add(new SubKey { KeyPath = subKeyPath }); } } // Process any Values foreach (string valueName in localKey.GetValueNames()) { string valueForName = localKey.GetValue(valueName).ToString(); KeyValues.Add(new KeyValue { Name = valueName, Value = valueForName }); } }