第一步下载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. MySQL分布式集群之MyCAT(转)

    原文地址:http://blog.itpub.net/29510932/viewspace-1664499/ 隔了好久,才想起来更新博客,最近倒腾的数据库从Oracle换成了MySQL,研究了一段时间 ...

  2. 临时解决系统中大量的TIME_WAIT连接

    今天,偶然间发现后台服务与数据库之间有大量的TIME_WAIT的连接: [root@localhost logs]# netstat -an | grep TIME_WAIT tcp a.a.a.a: ...

  3. Django project structure: how does static folder, STATIC_URL, STATIC_ROOT work

    So I've been messing up with Django(1.6+) project setting for quite sometime, this is what i finally ...

  4. DBN 入门学习资料整理

    建议按序阅读 1.Deep Learning 概述 Deep Learning(深度学习)学习笔记整理系列 : http://blog.csdn.net/zouxy09/article/details ...

  5. 行列式计算(C#)

    最近几天学习高等代数老师说要写个程序算行列式的结果,闲来无事就简单写了一下. 不多说了,上代码 using System; using System.Collections.Generic; usin ...

  6. sudo add-apt-repository no found解决方法

    sudo apt-get install python-software-propertiessudo apt-get install software-properties-common

  7. mySql中alter table的使用

    1.修改表名:alter table 原表名 rename to 新表名; 2.新增列:alter table 表名 add column 列名 varchar(20) ; 3.删除列:alter t ...

  8. Angularjs scope

    $scope: var myapp = angular.module('myapp', []); myapp .controller('parent', function ($scope,$timeo ...

  9. android中加载的html获取的宽高不正确

    wap页面使用 js库是zepto,按照惯例在$(function(){})中,来获取当前可视区的宽高,但得到的宽高却与预想的相差十万八千里. 原本android手机的浏览器设定的宽高基本是360*6 ...

  10. 算法小节(一)——斐波那契数列(java实现)

    看到公司的笔试题中有一道题让写斐波那契数列,自己忙里偷闲写了一下 什么是斐波那契数列:斐波那契数列指的是这样一个数列 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...