以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  求助:钉钉加解密  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=158893)

--  作者:水墨青花
--  发布时间:2020/12/6 16:21:00
--  求助:钉钉加解密
请问,钉钉加密解密可以使用微信加解密类型  WXBizCrypt(AppId, Token, EncodingAESKey) 吗?

用了钉钉的 Dim encryptor As DingTalkEncryptor = New DingTalkEncryptor(TOKEN,AES_KEY,CORP_ID),
返回错误:未定义类型 DingTalkEncryptor。

请问,该如何解决钉钉加解密的问题?

十分感谢!


--  作者:有点蓝
--  发布时间:2020/12/6 20:48:00
--  
这个是java的类型。到下载的。net的源码里找,好像是DingTalkCrypt
--  作者:水墨青花
--  发布时间:2020/12/7 10:48:00
--  

这个api是C#环境的DingTalkEncryptor.cs:

https://github.com/open-dingtalk/dingtalk-callback-Crypto/blob/main/DingTalkEncryptor.cs

是不是我不能直接使用,需要将该文件转换成 .dll文件,导入到Foxtable后才能正常使用?

谢谢1


--  作者:有点蓝
--  发布时间:2020/12/7 11:18:00
--  
到vs里建一个库项目,把代码复制到自己的项目里,编译成dll给foxtable引用
--  作者:水墨青花
--  发布时间:2020/12/7 16:43:00
--  
老师,搞不定呀!

我在vs prompt下用这个命令:csc /out:d:\\test\\DingTalkCrypt.dll /t:library d:\\test\\DingTalkCrypt.cs

返回错误如下:

Microsoft (R) Visual C# Compiler version 4.8.4084.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

DingTalkCrypt.cs(4,13): error CS0234: 命名空间“Suite”中不存在类型或命名空间名称“Corp”(是否缺少程序集引用?)


--  作者:有点蓝
--  发布时间:2020/12/7 16:59:00
--  
https://www.baidu.com/baidu?word=vs%20新建类库项目

--  作者:水墨青花
--  发布时间:2020/12/8 13:28:00
--  
老师,您好:

我把如下文件按照您上面给出的方法建了一个类库,生成 DTCrypt.dll 的文件,引入了Foxtable,但是在定义时:
Dim dingCrypt As New DTCrypt.DingTalkCrypt(Token,AesKey,CorpId)
给出编译错误:“DTCrypt.DingTalkCrypt”是 Friend,因此它在上下文中不可访问。

请问该怎么解决呢?谢谢!


DingTalkCrypto.cs 的code如下:

using System;
using System.Text;
using System.Security.Cryptography;
using System.Collections;
using System.IO;
using System.Net;

namespace DTCrypt
{
    class DingTalkCrypt
    {
......
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="token">钉钉开放平台上,开发者设置的token</param>
        /// <param name="encodingAesKey">钉钉开放台上,开发者设置的EncodingAESKey</param>
        /// <param name="suiteKey">钉钉开放平台上,开发者设置的suiteKey</param>
        public DingTalkCrypt(string token, string encodingAesKey, string suiteKey)
        {
            m_sToken = token;
            m_sSuiteKey = suiteKey;
            m_sEncodingAESKey = encodingAesKey;
        }

        public int EncryptMsg(string sReplyMsg, string sTimeStamp, string sNonce, ref string sEncryptMsg, ref string signature)
        {
.....

            string msgSigature = "";
            int ret = GenerateSignature(m_sToken, sTimeStamp, sNonce, raw, ref msgSigature);
            sEncryptMsg = raw;
            signature = msgSigature;
            return ret;
        }

        public int DecryptMsg(string sMsgSignature, string sTimeStamp, string sNonce, string sPostData, ref string sMsg)
        {
    .......
            return ret;
        }

        /// <summary>
        public int VerifyURL(string sMsgSignature, string sTimeStamp, string sNonce, string sEchoStr, ref string sReplyEchoStr)
        {
    .....
            return ret;
        }


    class Cryptography
    {
        public static UInt32 HostToNetworkOrder(UInt32 inval)
        {

        }

        public static Int32 HostToNetworkOrder(Int32 inval)
        {

        }

        public static string AES_decrypt(String Input, string EncodingAESKey, ref string corpid)
        {

        }

}


--  作者:有点蓝
--  发布时间:2020/12/8 13:38:00
--  
class DingTalkCrypt
改为
public class DingTalkCrypt

--  作者:水墨青花
--  发布时间:2020/12/8 14:23:00
--  
成功了!非常感谢!:-)