private static bool CacheKeyRepo(string strDomain) { bool bSuccess = false; try { string strSerialize = GetKeyRepository(strDomain); if (strSerialize.Substring(0, KEY_PROTO.Length) == KEY_PROTO) { using (IntCryptNetSC.Secure sc = new IntCryptNetSC.Secure()) { strSerialize = strSerialize.Substring(KEY_PROTO.Length, strSerialize.Length - KEY_PROTO.Length); // default key로 키 복호화 strSerialize = sc.AES_Decrypt("", "", strSerialize); } } MemoryStream stream = new MemoryStream(Convert.FromBase64String(strSerialize)); BinaryFormatter fmt = new BinaryFormatter(); KeyRepo_ = (KeyType)fmt.Deserialize(stream); bSuccess = true; } catch (Exception) { } return(bSuccess); }
private void Hash_Click(object sender, EventArgs e) { using (IntCryptNetSC.Secure sc = new IntCryptNetSC.Secure()) { txtEncrypt.Text = sc.MD5_Encoding(txtSource.Text); txtRecover.Text = sc.SHA1_Encoding(txtSource.Text); } }
private void FileExport(string strDomain, KeyType repo) { using (StreamWriter fs = new StreamWriter(File.Create(strDomain + ".key"))) using (MemoryStream stream = new MemoryStream()) using (IntCryptNetSC.Secure sc = new IntCryptNetSC.Secure()) { BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, repo); byte[] arr = stream.ToArray(); // default key로 키 암호화 string strEncKey = sc.AES_Encrypt("", "", Convert.ToBase64String(arr)); string str = string.Format("{0}{1}", KEY_PROTO, strEncKey); fs.WriteLine(str); } }
private void btnBase64_Click(object sender, EventArgs e) { try { using (IntCryptNetSC.Secure sc = new IntCryptNetSC.Secure()) { string strEnc = sc.Base64_Encoding(txtSource.Text); if (strEnc == null) { MessageBox.Show("실패"); return; } txtEncrypt.Text = strEnc; txtRecover.Text = sc.Base64_Decoding(txtEncrypt.Text); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }