private void ConnectButton_Click(object sender, EventArgs e) { try { if (this.WalletTextBox.Text.Length == 0) { this.errorLabel.Text = "마이닝 지갑 주소를 입력 해주세요."; this.WalletTextBox.Select(); } else { StringBuilder stringBuilder = new StringBuilder(); string text = this.WalletTextBox.Text; stringBuilder.Append("miningWallet=" + text); byte[] bytes = Encoding.UTF8.GetBytes(stringBuilder.ToString()); this.wReq = (HttpWebRequest)WebRequest.Create(new Uri(this.domain + "/api/syncCoin")); this.wReq.Method = "POST"; this.wReq.ContentType = "application/x-www-form-urlencoded"; this.wReq.ContentLength = (long)bytes.Length; this.PostDataStream = this.wReq.GetRequestStream(); this.PostDataStream.Write(bytes, 0, bytes.Length); this.PostDataStream.Close(); this.wResp = (HttpWebResponse)this.wReq.GetResponse(); this.respPostStream = this.wResp.GetResponseStream(); this.readerPost = new StreamReader(this.respPostStream, Encoding.Default); string end = this.readerPost.ReadToEnd(); if (JObject.Parse(end)["result"].ToString() == "True") { Minner minner = new Minner(text, end); this.Hide(); minner.Show(); } else { this.errorLabel.Text = "유효하지 않은 마이닝 지갑 입니다."; } } } catch (Exception ex) { int num = (int)MessageBox.Show("서버 연결에 실패 하였습니다. 재시도 해주세요"); } }
public string SHA256Hash(string data) { string text = ""; StringBuilder stringBuilder = new StringBuilder(); try { text = Marshal.PtrToStringAnsi(Minner.sha256_crypt(data)); foreach (byte b in Encoding.ASCII.GetBytes(text)) { stringBuilder.AppendFormat("{0:x2}", b); } } catch (Exception ex) { MessageBox.Show(ex.Message); } return(text); }