很少在线 2021-01-23 09:12 采纳率: 0%
浏览 10
已结题

请求把下列C#转成vb.net

public class DingTalkEncryptException : Exception
    {
        /**成功**/
        public static readonly int SUCCESS = 0;
        /**加密明文文本非法**/
        public readonly static int ENCRYPTION_PLAINTEXT_ILLEGAL = 900001;
        /**加密时间戳参数非法**/
        public readonly static int ENCRYPTION_TIMESTAMP_ILLEGAL = 900002;
        /**加密随机字符串参数非法**/
        public readonly static int ENCRYPTION_NONCE_ILLEGAL = 900003;
        /**不合法的aeskey**/
        public readonly static int AES_KEY_ILLEGAL = 900004;
        /**签名不匹配**/
        public readonly static int SIGNATURE_NOT_MATCH = 900005;
        /**计算签名错误**/
        public readonly static int COMPUTE_SIGNATURE_ERROR = 900006;
        /**计算加密文字错误**/
        public readonly static int COMPUTE_ENCRYPT_TEXT_ERROR = 900007;
        /**计算解密文字错误**/
        public readonly static int COMPUTE_DECRYPT_TEXT_ERROR = 900008;
        /**计算解密文字长度不匹配**/
        public readonly static int COMPUTE_DECRYPT_TEXT_LENGTH_ERROR = 900009;
        /**计算解密文字corpid不匹配**/
        public readonly static int COMPUTE_DECRYPT_TEXT_CORPID_ERROR = 900010;

        private static Dictionary<int, String> msgMap = new Dictionary<int, String>();
        static DingTalkEncryptException()
        {
            msgMap[SUCCESS] = "成功";
            msgMap[ENCRYPTION_PLAINTEXT_ILLEGAL] = "加密明文文本非法";
            msgMap[ENCRYPTION_TIMESTAMP_ILLEGAL] = "加密时间戳参数非法";
            msgMap[ENCRYPTION_NONCE_ILLEGAL] = "加密随机字符串参数非法";
            msgMap[SIGNATURE_NOT_MATCH] = "签名不匹配";
            msgMap[COMPUTE_SIGNATURE_ERROR] = "签名计算失败";
            msgMap[AES_KEY_ILLEGAL] = "不合法的aes key";
            msgMap[COMPUTE_ENCRYPT_TEXT_ERROR] = "计算加密文字错误";
            msgMap[COMPUTE_DECRYPT_TEXT_ERROR] = "计算解密文字错误";
            msgMap[COMPUTE_DECRYPT_TEXT_LENGTH_ERROR] = "计算解密文字长度不匹配";
            msgMap[COMPUTE_DECRYPT_TEXT_CORPID_ERROR] = "计算解密文字corpid不匹配";
        }

        private int code;
        public DingTalkEncryptException(int exceptionCode) : base(msgMap[exceptionCode])
        {
            this.code = exceptionCode;
        }
    }
  • 写回答

2条回答 默认 最新

  • The 祺℡ 2021-01-25 10:24
    关注
    Imports System
    Imports System.Collections.Generic
    
    Namespace ConsoleApp
    	Public Class DingTalkEncryptException
    		Inherits Exception
    		Public Shared SUCCESS As Integer
    		Public Shared ENCRYPTION_PLAINTEXT_ILLEGAL As Integer
    		Public Shared ENCRYPTION_TIMESTAMP_ILLEGAL As Integer
    		Public Shared ENCRYPTION_NONCE_ILLEGAL As Integer
    		Public Shared AES_KEY_ILLEGAL As Integer
    		Public Shared SIGNATURE_NOT_MATCH As Integer
    		Public Shared COMPUTE_SIGNATURE_ERROR As Integer
    		Public Shared COMPUTE_ENCRYPT_TEXT_ERROR As Integer
    		Public Shared COMPUTE_DECRYPT_TEXT_ERROR As Integer
    		Public Shared COMPUTE_DECRYPT_TEXT_LENGTH_ERROR As Integer
    		Public Shared COMPUTE_DECRYPT_TEXT_CORPID_ERROR As Integer
    		Private Shared msgMap As Dictionary(Of Integer, String)
    		Private code As Integer
    		Shared Sub New()
    			DingTalkEncryptException.SUCCESS = 0
    			DingTalkEncryptException.ENCRYPTION_PLAINTEXT_ILLEGAL = 900001
    			DingTalkEncryptException.ENCRYPTION_TIMESTAMP_ILLEGAL = 900002
    			DingTalkEncryptException.ENCRYPTION_NONCE_ILLEGAL = 900003
    			DingTalkEncryptException.AES_KEY_ILLEGAL = 900004
    			DingTalkEncryptException.SIGNATURE_NOT_MATCH = 900005
    			DingTalkEncryptException.COMPUTE_SIGNATURE_ERROR = 900006
    			DingTalkEncryptException.COMPUTE_ENCRYPT_TEXT_ERROR = 900007
    			DingTalkEncryptException.COMPUTE_DECRYPT_TEXT_ERROR = 900008
    			DingTalkEncryptException.COMPUTE_DECRYPT_TEXT_LENGTH_ERROR = 900009
    			DingTalkEncryptException.COMPUTE_DECRYPT_TEXT_CORPID_ERROR = 900010
    			DingTalkEncryptException.msgMap = New Dictionary(Of Integer, String)()
    			DingTalkEncryptException.msgMap(DingTalkEncryptException.SUCCESS) = "成功"
    			DingTalkEncryptException.msgMap(DingTalkEncryptException.ENCRYPTION_PLAINTEXT_ILLEGAL) =  "加密明文文本非法"
    			DingTalkEncryptException.msgMap(DingTalkEncryptException.ENCRYPTION_TIMESTAMP_ILLEGAL) = "加密时间戳参数非法"
    			DingTalkEncryptException.msgMap(DingTalkEncryptException.ENCRYPTION_NONCE_ILLEGAL) =  "加密随机字符串参数非法"
    			DingTalkEncryptException.msgMap(DingTalkEncryptException.SIGNATURE_NOT_MATCH) = "签名不匹配"
    			DingTalkEncryptException.msgMap(DingTalkEncryptException.COMPUTE_SIGNATURE_ERROR) = "签名计算失败"
    			DingTalkEncryptException.msgMap(DingTalkEncryptException.AES_KEY_ILLEGAL) = "不合法的aes key"
    			DingTalkEncryptException.msgMap(DingTalkEncryptException.COMPUTE_ENCRYPT_TEXT_ERROR) = "计算加密文字错误"
    			DingTalkEncryptException.msgMap(DingTalkEncryptException.COMPUTE_DECRYPT_TEXT_ERROR) =  "计算解密文字错误"
    			DingTalkEncryptException.msgMap(DingTalkEncryptException.COMPUTE_DECRYPT_TEXT_LENGTH_ERROR) =  "计算解密文字长度不匹配"
    			DingTalkEncryptException.msgMap(DingTalkEncryptException.COMPUTE_DECRYPT_TEXT_CORPID_ERROR) =  "计算解密文字corpid不匹配"
    		End Sub
    
    		Public Sub New(exceptionCode As Integer)
    			MyBase.[New](DingTalkEncryptException.msgMap(exceptionCode))
    			Me.code = exceptionCode
    		End Sub
    	End Class
    End Namespace
    
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题