This repository has been archived by the owner on Sep 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AuthCode.cs
76 lines (69 loc) · 2.3 KB
/
AuthCode.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
using System;
using System.Net;
using Ocrosoft;
namespace WXShare
{
/// <summary>
/// 网易云信短信验证码接口
/// </summary>
public class AuthCode
{
private static string appSecret = "db9cc835b811";
private static string appKey = "29b612d279f0c2691ac683251f3b6a8c";
/// <summary>
/// 发送短信验证码
/// </summary>
/// <param name="phone">手机号码</param>
/// <returns></returns>
public static bool SendAuthCode(String phone)
{
return true;
var nonce = OSecurity.GetRandomString(16);
var curTime = OSecurity.DateTimeToTimeStamp(DateTime.Now).ToString();
var sha1 = OSecurity.SHA1(appSecret + nonce + curTime);
var errcode = ORequest.RequestPost("https://api.netease.im/sms/sendcode.action",
"&phone=" + phone,
"code",
new WebHeaderCollection
{
{ "AppKey",appKey},
{"Nonce", nonce},
{"CurTime", curTime},
{"CheckSum", sha1}
});
if (errcode == "200")
{
return true;
}
return false;
}
/// <summary>
/// 短信验证码是否正确
/// </summary>
/// <param name="phone">手机号码</param>
/// <param name="code">短信验证码</param>
/// <returns></returns>
public static bool CheckAuthCode(String phone, String code)
{
return true;
var nonce = OSecurity.GetRandomString(16);
var curTime = OSecurity.DateTimeToTimeStamp(DateTime.Now).ToString();
var sha1 = OSecurity.SHA1(appSecret + nonce + curTime);
var errcode = ORequest.RequestPost("https://api.netease.im/sms/verifycode.action",
"&phone=" + phone,
"code",
new WebHeaderCollection
{
{"AppKey",appKey},
{"Nonce", nonce},
{"CurTime", curTime},
{"CheckSum", sha1}
});
if (errcode == "200")
{
return true;
}
return false;
}
}
}