-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
93 lines (82 loc) · 2.76 KB
/
Form1.cs
File metadata and controls
93 lines (82 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Net;
using System.Text;
using System.Windows.Forms;
namespace ProjectDotNet20
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
txtUrl.Text = "https://api-vinvoice.viettel.vn/auth/login";
txtContentType.Text = "application/json";
txtMethod.Text = "POST";
txtBody.Text = "{\"username\": \"0100109106-999\",\"password\": \"123456a@A\"}";
}
private void Form1_Load(object sender, EventArgs e)
{
string[] listCryptType = {"SHA1", "SHA256" };
this.cboCryptoType.DataSource = listCryptType;
}
private void btnGetBase64Cert_Click(object sender, EventArgs e)
{
try
{
txtBase64Cert.Text = Utilities.getBase64CertBySerial(txtSerialNo.Text);
}
catch (Exception ex)
{
txtBase64Cert.Text = ex.Message;
}
}
private void btnSignData_Click(object sender, EventArgs e)
{
try
{
txtDataSigned.Text = Utilities.signHashCert(txtDataToSign.Text, txtSerialNo.Text);
}
catch (Exception ex)
{
txtDataSigned.Text = ex.Message;
}
}
private void button1_Click_1(object sender, EventArgs e)
{
//string pzResponse = "";
//Utilities.webRequest2("http://192.168.1.211:8080/send"
// , "start_date=2022-08-02&end_date=2022-08-02", "", "", "multipart/form-data;"
// , "POST", false, out pzResponse
// );
//txtResponse.Text = pzResponse;
//return;
try
{
ServicePointManager.SecurityProtocol = (SecurityProtocolType)(0xc0 | 0x300 | 0xc00);
}
catch (Exception ex)
{
MessageBox.Show("ERR_Protocols: " + ex.Message);
}
string pzResponse = "";
Utilities.webRequest2(txtUrl.Text, txtBody.Text, "", txtHeader.Text,
txtContentType.Text, txtMethod.Text, chkGetByte.Checked, out pzResponse);
txtResponse.Text = pzResponse;
}
private void btnSignString_Click(object sender, EventArgs e)
{
try
{
txtDataSigned.Text = Utilities.signHashString(txtDataToSign.Text, txtSerialNo.Text, this.cboCryptoType.SelectedItem.ToString());
}
catch (Exception ex)
{
txtDataSigned.Text = ex.Message;
}
}
}
}