第一步下载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. Hibernate 开发流程

    Hibernate内部分装的技术:JDBC(Java Data Base Connectivity), JTA(Java Transaction API) , JNDI(Java Naming and ...

  2. 电脑用miniDP链接显示器后电脑没声音

    今天用笔记本T440s miniDP 链接戴尔U2515显示器的 DP 连接后发现笔记本没声音了 原因: miniDP 不仅能支持视频传输还支持音频, 所以声音就改为从显示器发出了 但是我想让电脑输出 ...

  3. Lae程序员小漫画(二),仅供一乐

    Lae软件开发,快乐程序员!

  4. jquery/js分割数组

    substr(star[,length]);//star起始位置 length截取的长度 substring(star,end);//star起始位置,end结束位置 都是以0开始的索引值

  5. Sqlserver 存储过程

    转载自:http://www.cnblogs.com/hoojo/archive/2011/07/19/2110862.html Transact-SQL中的存储过程,非常类似于Java语言中的方法, ...

  6. 【引】objective-c,6:Autorelease Pool

    参考博客: http://blog.leichunfeng.com/blog/2015/05/31/objective-c-autorelease-pool-implementation-princi ...

  7. Linux下得到毫秒级时间--C语言实现(转-度娘818)

    Linux下得到毫秒级时间--C语言实现 原文链接: http://www.cnblogs.com/nwf5d/archive/2011/06/03/2071247.html #ifdef HAVE_ ...

  8. xloader

    [1],先看一下整个系统的结构(软件是灵魂,硬件是驱体,再强大的灵魂力若没有躯体终将是游魂野鬼,再强壮的驱体若没有灵魂终将是植物人) 结构 作用 备注 硬件 一切软件的载体   xloader 引导u ...

  9. java return

    return语句的作用: 1.返回一个值,可以是任意类型的 2.使程序返回到操作系统,或者说是代表"已经做完,离开此方法" ---------------------------- ...

  10. linux 系统性能分析

    CPU篇 top 1时,看各个cpu是否均衡:看每个cpu的使用率分布是否合理 看load average的负载( 1分钟.5分钟.15分钟前到现在的平均值) 看内存的使用 看进程数运行.休眠数 M看 ...