第一步下载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#

/// <summary>
/// 解密
/// </summary>
/// <param name="EncryptMsg">需要解密的字串</param>
/// <param name="DecryptKey">金鑰</param>
/// <returns></returns>
/// <remarks></remarks>
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
/// <summary>
/// 加密
/// </summary>
/// <param name="Content">要加密的字串</param>
/// <param name="Algorithm">預設3</param>
/// <param name="KeyLength">預設0</param>
/// <param name="Password">金鑰</param>
/// <returns></returns>
/// <remarks></remarks>
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 CAPICOM

Module Decrypt
'Public Fire_Up, Login_OK, Pass1 As String
''' <summary>
''' 解密
''' </summary>
''' <param name="EncryptMsg">密文</param>
''' <param name="DecryptKey">密匙</param>
''' <returns>明文</returns>
''' <remarks></remarks>
Public Function DoDecryptCommand(ByVal EncryptMsg, ByVal DecryptKey, Optional ByVal Algorithm = , Optional ByVal KeyLength = )
'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 =
encryptedData.Algorithm.KeyLength =
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
''' <summary>
''' 加密
''' </summary>
''' <param name="Content">明文</param>
''' <param name="DecryptKey">密匙</param>
''' <param name="Algorithm">加密類型:0:RSA RC2;1:RSA RC4;2:DES;3:3DES</param>
''' <param name="KeyLength">密匙長度:0:CAPICOM_KEY_LENGTH_MAXIMUM;1:CAPICOM_KEY_LENGTH_40_BITS(40-bit);2:56-bit;3:128-bit;5:256;</param>
''' <returns>密文</returns>
''' <remarks></remarks>
Function DoEncryptCommand(ByVal Content, ByVal DecryptKey, Optional ByVal Algorithm = , Optional ByVal KeyLength = )
'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 =
encryptedData.Algorithm.KeyLength =
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 DoEncryptCommand End Module

Microsoft Capicom 2.1 On 64bit OS的更多相关文章

  1. Can Live View boot up images acquired from 64bit OS evidence?

    Some said Live View could only boot up images acquired from 32bit OS evidence. I have to say that it ...

  2. checking it the current os is a 32bit or 64bit version 检查操作系统是32位还是64位

    ) { Console.WriteLine("32bit os"); } ) { Console.WriteLine("64bit os"); }

  3. 操作系统Unix、Windows、Mac OS、Linux的故事

    电脑,计算机已经成为我们生活中必不可少的一部分.无论是大型的超级计算机,还是手机般小巧的终端设备,都跑着一个操作系统.正是这些操作系统,让那些硬件和芯片得意组合起来,让那些软件得以运行,让我们的世界在 ...

  4. 用Windows PowerShell 控制管理 Microsoft Office 365

    如果想要通过PowerShell控制管理Office365,首先要安装Microsoft Online Services Sign-In Assistant 7.0,链接如下 Microsoft On ...

  5. 检测到 LoaderLock:DLL"XXXX"正试图在OS加载程序锁内执行

    解决方法: ctrl+D+E或alt+ctl+e或使用菜单调试——>异常——>异常窗口——>Managed Debugging Assistants——>去掉LoaderLoc ...

  6. OGG-00782 - OGG 11.2.1.0.2 FOR Windows x64 Microsoft SQL Server

    OS ENV:主机名:           WIN-NO42QRNPMFAOS 名称:          Microsoft Windows Server 2008 R2 Datacenter OS ...

  7. win7 64bit+vs2010 操作注册表

    注册表五个根键 HKEY_CLASSES_ROOT--管理文件系统  HKEY_LOCAL_MACHINE--管理当前系统硬件配置  HKEY_LOCAL_USER--管理系统当前用户配置  HKEY ...

  8. Unix、Windows、Mac OS、Linux系统故事

    我们熟知的操作系统大概都是windows系列,近年来Apple的成功,让MacOS也逐渐走进普通用户.在服务器领域,恐怕Linux是无人不知无人不晓.他们都是操作系统,也在自己的领域里独领风骚.这都还 ...

  9. [转]操作系统Unix、Windows、Mac OS、Linux的故事

    [写得很江湖气,可惜找不到原作者了] 文章转自:http://blog.csdn.net/wenmingchan/article/details/49925379 http://www.jb51.ne ...

随机推荐

  1. 实现PageProcessor

    4.1 实现PageProcessor 这部分我们直接通过GithubRepoPageProcessor这个例子来介绍PageProcessor的编写方式.我将PageProcessor的定制分为三个 ...

  2. win32自绘按钮,使用GDI+(一)

    第一次写随笔,我本来想将win32窗口的标题栏设置成渐变色,像这样的效果 但发现找不到设置标题栏属性的api,SetWindowLong也只是增减窗口的固定的样式而已.所以想到一个思路,把标题栏去掉, ...

  3. 苹果Home键恢复(无工具篇)

    无工具法: 弹指神功.用手指轻轻弹Home,过了一阵子后可能会出现白色污垢,其后再重覆“弹”,直至正常为止.(亲测可用) 软件调试法.首先,打开任意一款应用程序,按住电源开关几秒钟,直到屏幕出现滑动关 ...

  4. 2.4G无线射频通信模块nRF24L01+开发笔记(基于MSP430RF6989与STM32f0308)(1.(2)有错误,详见更正)

    根据网上的nRF24L01+例程和TI提供的MSP430RF6989的硬件SPI总线例程编写程序,对硬件MSP-EXP430RF6989 Launch Pad+nRF24L01P射频模块(淘宝购买)进 ...

  5. java可变参数

    Java1.5增加了新特性:可变参数:适用于参数个数不确定,类型确定的情况,java把可变参数当做数组处理.注意:可变参数必须位于最后一项.当可变参数个数多余一个时,必将有一个不是最后一项,所以只支持 ...

  6. Surprise团队第三周项目总结

    Surprise团队第二周项目总结 项目进展 这周我们小组的项目在上周的基础上进行了补充,主要注重在注册登录界面的实现,以及关于数据库的一些学习. 在设计注册登录界面时,每一块的地方控件都不一样,比如 ...

  7. div各种距离 详细解释图

    详细博文介绍:http://blog.csdn.net/fswan/article/details/17238933

  8. iOS开发之直接使用UISearchBar

    iOS开发中经常需要使用SearchBar,我们可以选择使用UISearchBar+UISearchController或者UISearchBar+UISearchDisplayController( ...

  9. *** missing separator. Stop.

    在make命令后出现这种错误提示,是提示第2行没有分隔符. 例如: 1 target:prerequisites 2 command -- 改为: 1 target:prerequisites 2   ...

  10. 【jq】c#零基础学习之路(3)继承和虚方法

    c#只能继承一个基类和多个接口(0+) 父类:Human: class Human { public virtual Move() { Console.WriteLine("Human的虚方 ...