开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 511|回复: 4
收起左侧

[已解决] 不会写C# 来个师傅帮我改成易语言的谢谢

 关闭 [复制链接]
结帖率:76% (57/75)
发表于 2020-10-7 21:40:26 | 显示全部楼层 |阅读模式   河南省南阳市
5精币
using System.IO;using System.Text;using System.Net;using System.Net.Security;using System.Security.Cryptography;using System.Security.Cryptography.X509Certificates;using System;public class CsharpTest{    public static String HMACSHA1Text(String EncryptText, String EncryptKey)    {        HMACSHA1 hmacsha1 = new HMACSHA1();        hmacsha1.Key = System.Text.Encoding.UTF8.GetBytes(EncryptKey);        byte[] dataBuffer = System.Text.Encoding.UTF8.GetBytes(EncryptText);        byte[] hashBytes = hmacsha1.ComputeHash(dataBuffer);        return Convert.ToBase64String(hashBytes);    }    public static void Main(String[] args)    {        String url = "http://service-374wyg8x-1258247023.sh.apigw.tencentcs.com/release/bank_4ele";        String method = "POST";        String querys = "";        String postData = "accountNo=&idCard=&mobile=&name=";        //云市场分配的密钥Id        String secretId = "xxxx";        //云市场分配的密钥Key        String secretKey = "xxxx";        String source = "market";        String dt = DateTime.UtcNow.GetDateTimeFormats('r')[0];        url = url + "?" + querys;        String signStr = "x-date: " + dt + "\n" + "x-source: " + source;        String sign = HMACSHA1Text(signStr, secretKey);        String auth = "hmac id=\"" + secretId + "\", algorithm=\"hmac-sha1\", headers=\"x-date x-source\", signature=\"";        auth = auth + sign + "\"";        HttpWebRequest httpRequest = null;        HttpWebResponse httpResponse = null;        if (url.Contains("https://")) {            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);            httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));        } else {            httpRequest = (HttpWebRequest)WebRequest.Create(url);        }        httpRequest.Method = method;        httpRequest.ContentLength = postData.Length;        httpRequest.ContentType = "application/x-www-form-urlencoded";        httpRequest.Headers.Add("Authorization", auth);        httpRequest.Headers.Add("X-Source", source);        httpRequest.Headers.Add("X-Date", dt);        httpRequest.GetRequestStream().Write(System.Text.Encoding.ASCII.GetBytes(postData), 0, postData.Length);        try {            httpResponse = (HttpWebResponse)httpRequest.GetResponse();        } catch (WebException ex) {            httpResponse = (HttpWebResponse)ex.Response;        }        Console.WriteLine(httpResponse.StatusCode);        Console.WriteLine(httpResponse.Headers);        Stream st = httpResponse.GetResponseStream();        StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));        Console.WriteLine(reader.ReadToEnd());        Console.WriteLine("\n");    }    public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)    {        return true;    }}






上面代码改成易语言

最佳答案

查看完整内容

[e=0].版本 2 .支持库 spec .程序集 窗口程序集_启动窗口 .子程序 __启动窗口_创建完毕 main函数 (“”, “xxxx”, “xxxx”) .子程序 main函数 .参数 querys, 文本型, , url?后面带的数据 .参数 secretId, 文本型, , 云市场分配的密钥Id .参数 secretKey, 文本型, , 云市场分配的密钥Key .局部变量 url, 文本型 .局部变量 postData, 文本型 .局部变量 source, 文本型 .局部变量 dtime, 文本型 .局部变量 signStr, 文本型 ...

点评

才5个精币 楼主寒了1楼大佬的心血啊   湖南省怀化市  发表于 2020-10-8 00:29

回答提醒:如果本帖被关闭无法回复,您有更好的答案帮助楼主解决,请发表至 源码区 可获得加分喔。
友情提醒:本版被采纳的主题可在 申请荣誉值 页面申请荣誉值,获得 1点 荣誉值,荣誉值可兑换荣誉会员、终身vip用户组。
快捷通道:申请荣誉值无答案申请取消悬赏投诉有答案未采纳为最佳
结帖率:52% (14/27)
发表于 2020-10-7 21:40:27 | 显示全部楼层   江苏省苏州市
  
窗口程序集名保 留  保 留备 注
窗口程序集_启动窗口   
子程序名返回值类型公开备 注
__启动窗口_创建完毕  
main函数 (“”, “xxxx”, “xxxx”)
子程序名返回值类型公开备 注
main函数  
参数名类 型参考可空数组备 注
querys文本型url?后面带的数据
secretId文本型云市场分配的密钥Id
secretKey文本型云市场分配的密钥Key
变量名类 型静态数组备 注
url文本型 
postData文本型 
source文本型 
dtime文本型 
signStr文本型 
sign文本型 
auth文本型 
协议头文本型 
str文本型 
url = http://service-374wyg8x-12582470 ... m/release/bank_4ele
source = “market”
dtime = “Wed, 07 Oct 2020 15:23:27 GMT”  ' 取先行时间 不知道易语言怎么实现
signStr = “x-date: ” + dtime + “\n”“x-source: ” + source
sign = 校验_取hmac_sha1 (signStr, secretKey)  ' 取sign
auth = “hmac id=”#引号“xxxx”#引号“, algorithm=”#引号“hmac-sha1”#引号“, headers=”#引号“x-date x-source”#引号“, signature=”#引号
auth = auth + sign + #引号
url = url + “?” + querys
postData = “accountNo=&idCard=&mobile=&name=”  ' 里面应该是有参数的
协议头 = “ContentType: application/x-www-form-urlencoded”#换行符
协议头 = 协议头 + “Authorization: ” + auth + #换行符
协议头 = 协议头 + “X-Source: ” + source + #换行符
协议头 = 协议头 + “X-Date: ” + dtime + #换行符
str = 网页_访问S (url, 1, postData, , , 协议头)
调试输出 (str)
子程序名返回值类型公开备 注
校验_取hmac_sha1文本型 
参数名类 型参考可空数组备 注
word文本型
key文本型
变量名类 型静态数组备 注
Js对象 
return文本型 
线程_初始化COM库 ()  ' 线程中请初始化COM  否则会出错
Js.创建 (“ScriptControl”, )
Js.写属性 (“Language”, “JavaScript”)
Js.数值方法 (“AddCode”, #常量1 )  ' 请在常量_Js中放入调试成功的JS代码段
return = Js.通用方法 (“eval”, “HmacSHA1_Encrypt”“('” + word + “','” + key + “')”).取文本 ()
线程_取消COM库 ()
返回 (return)


i支持库列表   支持库注释   
spec特殊功能支持库

点评

牛逼的大佬   湖南省怀化市  发表于 2020-10-8 00:30

评分

参与人数 1荣誉 +1 收起 理由
笨潴 + 1 热心帮助他人,荣誉+1,希望继续努力(*^__^*) 嘻嘻!

查看全部评分

回复

使用道具 举报

结帖率:52% (14/27)
发表于 2020-10-7 23:34:12 | 显示全部楼层   江苏省苏州市
demo.e (856.89 KB, 下载次数: 7)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 诚聘英才| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 800073686,邮箱:800073686@b.qq.com
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表