private void btnKeyExport_Click(object sender, EventArgs e) { try { RegistryKey SubKeyDefault = Registry.LocalMachine.OpenSubKey(SUBKEYROOT, true); if (SubKeyDefault == null) { MessageBox.Show("키가 존재하지 않습니다."); return; } string[] arrDomainKey = SubKeyDefault.GetSubKeyNames(); foreach (string strDomain in arrDomainKey) { KeyType repo = new KeyType(); RegistryKey KeyDomain = SubKeyDefault.OpenSubKey(strDomain); string[] arrApp = KeyDomain.GetSubKeyNames(); foreach (string strApp in arrApp) { RegistryKey Key = KeyDomain.OpenSubKey(strApp); byte [] key = (byte[])Key.GetValue("key"); byte [] iv = (byte[])Key.GetValue("iv"); repo.Add(strApp, new KeyValueType(key, iv)); Trace.WriteLine(strApp); } FileExport(strDomain, repo); } MessageBox.Show("성공"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private bool CacheKeyRepoFromReg(string strDomain) { bool bSuccess = false; try { RegistryKey SubKeyDefault = Registry.LocalMachine.OpenSubKey(SUBKEYROOT, true); if (SubKeyDefault == null) { throw new Exception(); } KeyType repo = new KeyType(); RegistryKey KeyDomain = SubKeyDefault.OpenSubKey(strDomain); string[] arrApp = KeyDomain.GetSubKeyNames(); foreach (string strApp in arrApp) { RegistryKey Key = KeyDomain.OpenSubKey(strApp); byte[] key = (byte[])Key.GetValue("key"); byte[] iv = (byte[])Key.GetValue("iv"); repo.Add(strApp, new KeyValueType(key, iv)); } keyman_.Add(strDomain, repo); Trace.WriteLine(string.Format("IntCryptLib::CacheKeyRepoFromReg : {0}", strDomain)); bSuccess = true; } catch (Exception) { Trace.WriteLine(string.Format("IntCryptLib::CacheKeyRepoFromReg [Failed] : {0}", strDomain)); } return(bSuccess); }