博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Microsoft Capicom 2.1 On 64bit OS
阅读量:7176 次
发布时间:2019-06-29

本文共 5194 字,大约阅读时间需要 17 分钟。

第一步下载capicom.dll

 http://files.cnblogs.com/files/chen110xi/DLL.7z

第二步注册capicom.dll至SysWow64

 

第三步VS中设置

1.添加com,capicom.dll的参考

2.COM 元件需注意是否內嵌 Interop 型別,设置为false(只有.NET 4.0+需要)

3.专案是否设置为x86

第四步开发

http://files.cnblogs.com/files/chen110xi/KeyC.7z

C#

/// /// 解密/// /// 需要解密的字串/// 金鑰/// 
///
public static string DoDecryptCommand(string EncryptMsg,string DecryptKey){ string strRetrun = string.Empty; // Dim Contents CAPICOM.EncryptedData EncryptedData = new CAPICOM.EncryptedData(); //dynamic EncryptedData = null; // Create the EncryptedData object. //EncryptedData = Interaction.CreateObject("CAPICOM.EncryptedData"); // Set decryption password. EncryptedData.SetSecret(DecryptKey); // Load the encrypted message. // LoadFile FileName, Message // Now decrypt it. EncryptedData.Decrypt(EncryptMsg); //DoDecryptCommand = EncryptedData.Content strRetrun = EncryptedData.Content; // Free resources. EncryptedData = null; return strRetrun;}// End DoDecryptCommand/// /// 加密/// /// 要加密的字串/// 預設3/// 預設0/// 金鑰///
///
public static string DoEncryptCommand(string Content, CAPICOM.CAPICOM_ENCRYPTION_ALGORITHM Algorithm, CAPICOM.CAPICOM_ENCRYPTION_KEY_LENGTH KeyLength, string Password){ string functionReturnValue = ""; CAPICOM.EncryptedData EncryptedData = new CAPICOM.EncryptedData(); // Set algorithm, key size, and encryption password. EncryptedData.Algorithm.Name = Algorithm; EncryptedData.Algorithm.KeyLength = KeyLength; EncryptedData.SetSecret(Password); // Now encrypt it. EncryptedData.Content = Content; functionReturnValue = EncryptedData.Encrypt(); // Free resources. EncryptedData = null; return functionReturnValue;}

VB

Imports CAPICOMModule Decrypt    'Public Fire_Up, Login_OK, Pass1 As String    '''     ''' 解密    '''     ''' 密文    ''' 密匙    ''' 
明文
'''
Public Function DoDecryptCommand(ByVal EncryptMsg, ByVal DecryptKey, Optional ByVal Algorithm = 0, Optional ByVal KeyLength = 0) 'Dim Contents 'Dim EncryptedData '' Create the EncryptedData object. 'EncryptedData = CreateObject("CAPICOM.EncryptedData") '' Set decryption password. 'EncryptedData.Algorithm.Name = Algorithm 'EncryptedData.Algorithm.KeyLength = KeyLength 'EncryptedData.SetSecret(DecryptKey) '' Load the encrypted message. '' LoadFile FileName, Message '' Now decrypt it. 'EncryptedData.Decrypt(EncryptMsg) 'Nelson Mark 'Contents = Trim(EncryptedData.Content) 'Nelson Mark 'Pass1 = Contents 'EncryptedData = Nothing 'Return Contents 'Nelson Mark Dim encryptedData As New CAPICOM.EncryptedData encryptedData.Algorithm.Name = 0 encryptedData.Algorithm.KeyLength = 0 encryptedData.SetSecret(DecryptKey, CAPICOM_SECRET_TYPE.CAPICOM_SECRET_PASSWORD) encryptedData.Decrypt(EncryptMsg) Return encryptedData.Content End Function 'Const CAPICOM_ENCRYPTION_ALGORITHM_RC2 = 0 'Const CAPICOM_ENCRYPTION_ALGORITHM_RC4 = 1 'Const CAPICOM_ENCRYPTION_ALGORITHM_DES = 2 'Const CAPICOM_ENCRYPTION_ALGORITHM_3DES = 3 'Const CAPICOM_ENCRYPTION_ALGORITHM_AES = 4 'Const CAPICOM_ENCRYPTION_KEY_LENGTH_MAXIMUM = 0 'Const CAPICOM_ENCRYPTION_KEY_LENGTH_40_BITS = 1 'Const CAPICOM_ENCRYPTION_KEY_LENGTH_56_BITS = 2 'Const CAPICOM_ENCRYPTION_KEY_LENGTH_128_BITS = 3 'Const CAPICOM_ENCRYPTION_KEY_LENGTH_192_BITS = 4 'Const CAPICOM_ENCRYPTION_KEY_LENGTH_256_BITS = 5 ''' ''' 加密 ''' ''' 明文 ''' 密匙 ''' 加密類型:0:RSA RC2;1:RSA RC4;2:DES;3:3DES ''' 密匙長度:0:CAPICOM_KEY_LENGTH_MAXIMUM;1:CAPICOM_KEY_LENGTH_40_BITS(40-bit);2:56-bit;3:128-bit;5:256; '''
密文
'''
Function DoEncryptCommand(ByVal Content, ByVal DecryptKey, Optional ByVal Algorithm = 0, Optional ByVal KeyLength = 0) 'Dim EncryptedData '' Create the EncryptedData object. 'EncryptedData = CreateObject("CAPICOM.EncryptedData") '' Set algorithm, key size, and encryption password. 'EncryptedData.Algorithm.Name = Algorithm 'EncryptedData.Algorithm.KeyLength = KeyLength 'EncryptedData.SetSecret(DecryptKey) '' Now encrypt it. 'EncryptedData.Content = Content 'DoEncryptCommand = EncryptedData.Encrypt '' Free resources. 'EncryptedData = Nothing Dim encryptedData = New EncryptedDataClass() encryptedData.Content = Content encryptedData.Algorithm.Name = 0 encryptedData.Algorithm.KeyLength = 0 encryptedData.SetSecret(DecryptKey, CAPICOM_SECRET_TYPE.CAPICOM_SECRET_PASSWORD) Return encryptedData.Encrypt(CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_BASE64) 'Dim functionReturnValue = "" 'Dim EncryptedData = New CAPICOM.EncryptedData() 'EncryptedData.Algorithm.Name = Algorithm 'EncryptedData.Algorithm.KeyLength = KeyLength 'EncryptedData.SetSecret(DecryptKey) 'EncryptedData.Content = Content 'functionReturnValue = EncryptedData.Encrypt() 'Return functionReturnValue End Function ' End DoEncryptCommandEnd Module

 

 

转载地址:http://gubzm.baihongyu.com/

你可能感兴趣的文章
用mysql查询某字段是否有索引
查看>>
ubuntu 查看进程,查看服务
查看>>
Cisco DHCP Snooping + IPSG 功能实现
查看>>
Linux命令_用户身份切换
查看>>
学习在.NET Core中使用RabbitMQ之启动和基础(一)
查看>>
支付业务的数据库表的设计
查看>>
php面试题二--解决网站大流量高并发方案(从url到硬盘来解决高并发方案总结)...
查看>>
PHP 16 个编程法则
查看>>
【微信】2.微信小程序开发--官方开发工具使用说明
查看>>
RedisTemplate访问Redis数据结构
查看>>
面试如何回答优化数据库
查看>>
SuperSocket与Netty之实现protobuf协议,包括服务端和客户端
查看>>
ASP.NET CORE系列【二】使用Entity Framework Core进行增删改查
查看>>
js如何返回两个数的商的整数和余数部分?
查看>>
AIDL基本使用
查看>>
MySQL中间件之ProxySQL(6):管理后端节点
查看>>
Mathematica 取整函数
查看>>
使用Java进行串口SerialPort通讯
查看>>
(转)Awsome Domain-Adaptation
查看>>
利用cwRsync客户端将Windows下文件同步到Linux
查看>>