• 大小: 157KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: C#
  • 标签:

资源简介

C#调用Delphi的dll以实现标准的AES加密解密,Reg.dll为Delphi写的AES加密解密动态链接库

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
//C#实现调用Delphi的dllReg.dll是Delphi实现AES标准算法
namespace 调用Delphi的dll
{
    public partial class MainFrm : Form
    {
        //构造函数
        public enum TKeyBit { Bits128 Bits192 Bits256 };
        //public static string strPath = Application.StartupPath + “\\Reg.dll“;
        #region 调用Reg.dll实现AES加密
        /// 
        /// 加密
        /// 

        /// 要加密码的内容
        /// 加密密匙
        /// 密匙长度
        [DllImport(“Reg.dll“ CharSet = CharSet.Ansi CallingConvention = CallingConvention.StdCall)]
        public static extern string EncryptString(string Value string Key TKeyBit KeyBit);
        #endregion
        #region 调用Reg.dll实现AES解密
        /// 
        /// 解密
        /// 

        /// 要加密码的内容
        /// 加密密匙
        /// 密匙长度
         [DllImport(“Reg.dll“ CharSet = CharSet.Ansi CallingConvention = CallingConvention.StdCall)]
         public static extern string DecryptString(string Value string Key TKeyBit KeyBit);
        #endregion
         public MainFrm()
        {
            InitializeComponent();
        }

         private void btEnc_Click(object sender EventArgs e)
        {
            if (this.rtxtSrcStr.Text.Trim() == ““)
            {
                MessageBox.Show(“请输入要进行加密的字符串!““提示!“MessageBoxButtons.OK MessageBoxIcon.Information);
            }
            else
            {
                if (this.cbKeyBit.SelectedItem.ToString() == “128位“)
                {
                    //调用Reg.dll的加密函数
                    this.rtxtEncStr.Text = EncryptString(this.rtxtSrcStr.Text.Trim() this.txtLedKey.Text.Trim() TKeyBit.Bits128);
                }
                else if (this.cbKeyBit.SelectedItem.ToString() == “192位“)
                {
                    //调用Reg.dll的加密函数
                    this.rtxtEncStr.Text = EncryptString(this.rtxtSrcStr.Text.Trim() this.txtLedKey.Text.Trim() TKeyBit.Bits192);
                }
                else if (this.cbKeyBit.SelectedItem.ToString() == “256位“)
                {
                    //调用Reg.dll的加密函数
                    this.rtxtEncStr.Text = EncryptString(this.rtxtSrcStr.Text.Trim() this.txtLedKey.Text.Trim() TKeyBit.Bits256);
                }

            }
        }

         private void btDec_Click(object sender EventArgs e)
        {
            if (this.rtxtEncStr.Text.Trim().ToString()==““ )
            {
                MessageBox.Show(“请输入要进行解密的字符串!“ “提示!“ MessageBoxButtons.OK MessageBoxIcon.Information);
            }
            else
            {
                i

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        944  2011-04-07 11:00  VS调用Delphi的dll\VS调用Delphi的dll.sln

    ..A..H.     16896  2011-03-07 12:17  VS调用Delphi的dll\VS调用Delphi的dll.suo

     文件     141824  2006-09-26 01:09  VS调用Delphi的dll\调用Delphi的dll\bin\Debug\Reg.dll

     文件      35328  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\bin\Debug\调用Delphi的dll.exe

     文件      28160  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\bin\Debug\调用Delphi的dll.pdb

     文件      14328  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\bin\Debug\调用Delphi的dll.vshost.exe

     文件       5615  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\MainFrm.cs

     文件      14483  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\MainFrm.Designer.cs

     文件      20614  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\MainFrm.resx

     文件       1019  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\obj\Debug\调用Delphi的dll.csproj.FileListAbsolute.txt

     文件        849  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\obj\Debug\调用Delphi的dll.csproj.GenerateResource.Cache

     文件      35328  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\obj\Debug\调用Delphi的dll.exe

     文件      10228  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\obj\Debug\调用Delphi的dll.MainFrm.resources

     文件      28160  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\obj\Debug\调用Delphi的dll.pdb

     文件        180  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\obj\Debug\调用Delphi的dll.Properties.Resources.resources

     文件        501  2011-04-08 09:59  VS调用Delphi的dll\调用Delphi的dll\Program.cs

     文件       1494  2011-03-07 12:15  VS调用Delphi的dll\调用Delphi的dll\Properties\AssemblyInfo.cs

     文件       2886  2011-04-07 11:00  VS调用Delphi的dll\调用Delphi的dll\Properties\Resources.Designer.cs

     文件       5612  2011-04-07 11:00  VS调用Delphi的dll\调用Delphi的dll\Properties\Resources.resx

     文件       1103  2011-04-07 11:00  VS调用Delphi的dll\调用Delphi的dll\Properties\Settings.Designer.cs

     文件        249  2011-04-07 11:00  VS调用Delphi的dll\调用Delphi的dll\Properties\Settings.settings

     文件       9662  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\set.ico

     文件       5481  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\调用Delphi的dll.csproj

     文件        515  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\调用Delphi的dll.csproj.user

     目录          0  2011-04-08 09:59  VS调用Delphi的dll\调用Delphi的dll\obj\Debug\Refactor

     目录          0  2011-04-07 11:00  VS调用Delphi的dll\调用Delphi的dll\obj\Debug\TempPE

     目录          0  2011-03-07 11:53  VS调用Delphi的dll\调用Delphi的dll\bin\Debug

     目录          0  2011-03-07 12:16  VS调用Delphi的dll\调用Delphi的dll\obj\Debug

     目录          0  2011-04-08 09:59  VS调用Delphi的dll\调用Delphi的dll\bin

     目录          0  2011-04-07 11:00  VS调用Delphi的dll\调用Delphi的dll\obj

............此处省略7个文件信息

评论

共有 条评论

相关资源