private static bool IsValidKey(string value) { return(KeyType.ContainsKey(value)); }
public bool GetKeyIv(string strDomain, string strApp, ref byte[] key, ref byte[] iv) { bool bSuccess = false; const string HTTP_PRE = "http://"; const string HTTPS_PRE = "https://"; try { if (strDomain.Length == 0 && strApp.Length == 0) { key = default_key; iv = default_iv; } else { if (strDomain.IndexOf(HTTP_PRE) == 0 || strDomain.IndexOf(HTTPS_PRE) == 0) { if (!KeyRepo_.ContainsKey(strApp)) { CacheKeyRepo(strDomain); } KeyValueType keyv = new KeyValueType(); if (!KeyRepo_.TryGetValue(strApp, out keyv)) { throw new Exception(); } key = keyv.Key; iv = keyv.Value; } else { string strSubKey = SUBKEYROOT + strDomain; RegistryKey SubKeyDefault = Registry.LocalMachine.OpenSubKey(strSubKey, false); if (SubKeyDefault == null) { throw new Exception(); } RegistryKey RKey = SubKeyDefault.OpenSubKey(strApp, false); if (RKey == null) { throw new Exception(); } key = (byte[])RKey.GetValue("key"); iv = (byte[])RKey.GetValue("iv"); if (key == null || iv == null) { throw new Exception(); } } } bSuccess = true; } catch (Exception) { } return(bSuccess); }