5 Star 0 Fork 0

巨量云 / juliang-c-sdk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
UrlUtils.cs 3.93 KB
一键复制 编辑 原始数据 按行查看 历史
王全 提交于 2024-04-26 14:51 . 修改http提取的demo
using System;
using System.Collections;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
namespace API{
static class Endpoint{
// private static string Regoin = "http://192.168.10.63:8087";
private static string Regoin = "http://v2.api.juliangip.com";
internal enum url : byte{
[Description("/users/getbalance")]
USERS_GETBALANCE,
[Description("/users/getAllOrders")]
USERS_GETALLORDERS,
[Description("/users/getCity")]
USERS_GETCITY,
[Description("/dynamic/getips")]
DYNAMIC_GETIPS,
[Description("/dynamic/check")]
DYNAMIC_CHECK,
[Description("/dynamic/setwhiteip")]
DYNAMIC_SETWHITEIP,
[Description("/dynamic/getwhiteip")]
DYNAMIC_GETWHITEIP,
[Description("/dynamic/replaceWhiteIp")]
DYNAMIC_REPLACEWHITEIP,
[Description("/dynamic/remain")]
DYNAMIC_REMAIN,
[Description("/dynamic/balance")]
DYNAMIC_BALANCE,
[Description("/alone/getips")]
ALONE_GETIPS,
[Description("/alone/setwhiteip")]
ALONE_SETWHITEIP,
[Description("/alone/getwhiteip")]
ALONE_GETWHITEIP,
[Description("/alone/replaceWhiteIp")]
ALONE_REPLACEWHITEIP,
[Description("/unlimited/getips")]
UNLIMITED_GETIPS,
[Description("/unlimited/setwhiteip")]
UNLIMITED_SETWHITEIP,
[Description("/unlimited/getwhiteip")]
UNLIMITED_GETWHITEIP,
[Description("/unlimited/replaceWhiteIp")]
UNLIMITED_REPLACEWHITEIP,
[Description("/postpay/getips")]
POSTPAY_GETIPS,
[Description("/postpay/check")]
POSTPAY_CHECK,
[Description("/postpay/setwhiteip")]
POSTPAY_SETWHITEIP,
[Description("/postpay/getwhiteip")]
POSTPAY_GETWHITEIP,
[Description("/postpay/replaceWhiteIp")]
POSTPAY_REPLACEWHITEIP,
[Description("/company/postpay/getips")]
COMPANY_POSTPAY_GETIPS,
[Description("/company/postpay/setwhiteip")]
COMPANY_POSTPAY_SETWHITEIP,
[Description("/company/postpay/getwhiteip")]
COMPANY_POSTPAY_GETWHITEIP,
[Description("/company/postpay/delwhiteip")]
COMPANY_POSTPAY_DELWHITEIP,
}
public static string GetDescription(this Enum enumValue)
{
FieldInfo fieldInfo = enumValue.GetType().GetField(enumValue.ToString());
DescriptionAttribute[] attrs =
fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false) as DescriptionAttribute[];
return attrs.Length > 0 ? Regoin+attrs[0].Description : Regoin+enumValue.ToString();
}
public static string GetParams<TK,TV>(Dictionary<TK,TV> dic)
{
string str = "";
string key = "";
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
//先对参数字典进行排序
dic = dic.OrderBy(i => i.Key).ToDictionary(i =>i.Key,i =>i.Value);
foreach(var obj in dic){
Console.WriteLine($"{obj.Key.ToString()}:{obj.Value.ToString()}");
if(obj.Key != null && String.Equals(obj.Key,"key")){
key = obj.Value+"";
continue;
}
if(obj.Value == null || (obj.Value+"").Trim() == ""){
continue;
}
str += obj.Key+"="+obj.Value+"&";
}
byte[] buffer = Encoding.Default.GetBytes(str+$"key={key}");
byte[] somme = md5.ComputeHash(buffer);
string sign = "";
foreach(byte s in somme){
sign += s.ToString("x2");
}
str += $"sign={sign}";
return str;
}
}
}
1
https://gitee.com/juliangip/juliang-c-sdk.git
git@gitee.com:juliangip/juliang-c-sdk.git
juliangip
juliang-c-sdk
juliang-c-sdk
master

搜索帮助