-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathForm1.cs
104 lines (85 loc) · 3.25 KB
/
Form1.cs
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
94
95
96
97
98
99
100
101
102
103
104
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace OAuthSig
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
private void textBox7_TextChanged(object sender, EventArgs e)
{
}
private void btnGenerate_Click(object sender, EventArgs e)
{
OAuth.OAuthBase.SignatureTypes signatureType = OAuth.OAuthBase.SignatureTypes.HMACSHA1;
string normalizedUrl;
string normalizedRequestParameters;
OAuth.OAuthBase myOAuth = new OAuth.OAuthBase();
try
{
Uri uri = new Uri(txtURI.Text);
string consumerKey = txtConsKey.Text;
string consumerSecret = txtConsSecret.Text;
string token = txtToken.Text;
string tokenSecret = txtTokenSecret.Text;
string httpMethod = drpHTTPMethod.SelectedItem.ToString();
string timeStamp = txtTimestamp.Text;
string nonce = txtNonce.Text;
if (string.IsNullOrEmpty(timeStamp))
{
timeStamp = myOAuth.GenerateTimeStamp();
txtTimestamp.Text = timeStamp;
}
if (string.IsNullOrEmpty(nonce))
{
nonce = myOAuth.GenerateNonce();
txtNonce.Text = nonce;
}
switch (drpSigMethod.SelectedIndex)
{
case 0:
signatureType = OAuth.OAuthBase.SignatureTypes.HMACSHA1;
break;
case 1:
signatureType = OAuth.OAuthBase.SignatureTypes.PLAINTEXT;
break;
case 2:
signatureType = OAuth.OAuthBase.SignatureTypes.RSASHA1;
break;
}
myOAuth.includeVersion = chkVersion.Checked;
string signature = myOAuth.GenerateSignature(uri, consumerKey, consumerSecret,
token, tokenSecret, httpMethod, timeStamp, nonce, signatureType,
out normalizedUrl, out normalizedRequestParameters);
txtRawSig.Text = signature;
txtEncodedSig.Text = myOAuth.UrlEncode(signature);
txtGenURL.Text = normalizedUrl + "?" + normalizedRequestParameters + "&oauth_signature=" + txtEncodedSig.Text;
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
}
private void Form1_Load(object sender, EventArgs e)
{
drpSigMethod.SelectedIndex = 0;
drpHTTPMethod.SelectedIndex = 0;
}
private void label13_Click(object sender, EventArgs e)
{
}
}
}