临时急用到C语言,望各位高手救救俺~~~~很简单的问题

wtucel 2006-09-21 12:04:44
我有3个字符串常量:a,b,c,其中c是取b的后6位;
然后3个常量组合和赋值给d,d="/t&a&/t&/b&/tc"(不知道怎么连接的,反正中间加个/t)
然后需要将d进行加密,调用windows下面的组件capicom.dll进行DES加密
我需要取得返回值

就这样的,那位大侠给个代码,解决马上给分,分不够再加。
...全文
691 21 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouyan024 2006-09-22
  • 打赏
  • 举报
回复
http://www.blog.dov.cn/blog/user1/3/archives/2006/22347.html#
自己看看
wtucel 2006-09-22
  • 打赏
  • 举报
回复
谢谢jixingzhong,csrwgs,也谢谢大家热心的帮助,我才能解决问题。
csrwgs 2006-09-22
  • 打赏
  • 举报
回复
上面是我按照MSDN上的说明作的,测试可以。
地址是:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/seccrypto/security/using_capicom.asp
csrwgs 2006-09-22
  • 打赏
  • 举报
回复
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CAPICOM;
csrwgs 2006-09-22
  • 打赏
  • 举报
回复
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string encryptedmessage;
string decryptmessage;
private void button1_Click(object sender, EventArgs e)
{
CAPICOM.EncryptedData message = new EncryptedData();
message.Content = "csrwgs001";
message.SetSecret("csrwgs", CAPICOM_SECRET_TYPE.CAPICOM_SECRET_PASSWORD);
message.Algorithm.Name = CAPICOM_ENCRYPTION_ALGORITHM.CAPICOM_ENCRYPTION_ALGORITHM_DES;
encryptedmessage=message.Encrypt(CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_ANY);
if (encryptedmessage.Length < 1)
MessageBox.Show("no message to be encrypt");
else
MessageBox.Show("lenth of message is \n"+encryptedmessage);


}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button2_Click(object sender, EventArgs e)
{
CAPICOM.EncryptedData message = new EncryptedData();
message.SetSecret("csrwgs", CAPICOM_SECRET_TYPE.CAPICOM_SECRET_PASSWORD);

message.Decrypt(encryptedmessage);
decryptmessage = message.Content;

if (decryptmessage.Length < 1)
MessageBox.Show("no message to be encrypt");
else
MessageBox.Show("lenth of message is \n" + decryptmessage);
}
sakas 2006-09-22
  • 打赏
  • 举报
回复
可以按照DES算法 自己写一个啊
yinjun2004 2006-09-22
  • 打赏
  • 举报
回复
DES是怎么玩的?
Arthur_ 2006-09-21
  • 打赏
  • 举报
回复
差了半天也没有找到你说的dll资料,惭愧
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<window.h>

int main(void)
{
char *a="hello";
char *b="worldhelloagain";
char *c="oagain";
char *buf;
int len=strlen(a)+strlen(b)+strlen(c)+7;
d=malloc(sizeof(char)*len+1);
sprintf(d,"/t&%s&/t&/%s&/t%s",a,b,c);
/*如果知道dll的入口函数就好了,比如是int entry(char *str)
HINSTANCE hinst=Loadlibrary("****.dll");
typedef int (*func)(char *str);
func=GetProcAddress(hinst,"entry");
返回值=func(d);
freelibrary(hinst)
*/
}
ModoRang 2006-09-21
  • 打赏
  • 举报
回复
不懂,帮顶了。
wtucel 2006-09-21
  • 打赏
  • 举报
回复
我就是想要问capicom.dll进行DES加密的函数接口呢~~~我只知道vbscript下面的用法
Function EncryptMessage(Inputstr,KeyStr)
Dim msg
Set msg = CreateObject("capicom.encrypteddata")
msg.Algorithm.Name = CAPICOM_ENCRYPTION_ALGORITHM_DES
msg.SetSecret KeyStr
msg.Content = Inputstr
Dim str
str = msg.Encrypt(CAPICOM_ENCODE_BASE64)
EncryptMessage = str
End Function
Arthur_ 2006-09-21
  • 打赏
  • 举报
回复
capicom.dll进行DES加密function is ?
iambic 2006-09-21
  • 打赏
  • 举报
回复
DES啊,不懂。
deng_2518 2006-09-21
  • 打赏
  • 举报
回复
关注!
rw99yy 2006-09-21
  • 打赏
  • 举报
回复
char *a="hello";
char *b="worldhelloagain";
char *c="oagain";
char *buf;
int len=strlen(a)+strlen(b)+strlen(c)+7;
d=malloc(sizeof(char)*len+1);
sprintf(d,"/t&%s&/t&/%s&/t%s",a,b,c);
wtucel 2006-09-21
  • 打赏
  • 举报
回复
谢谢楼上的
下面的链接打不开啊
http://vckbase.com/document/viewdoc/?id=1493
http://vckbase.com/document/viewdoc/?id=1518
jixingzhong 2006-09-21
  • 打赏
  • 举报
回复
最简单的方式是加载类型库,
然后就可以类似 VB中的,
定义一个对象, 然后调用其成员即可 ...

具体看
示例三、加载类型库,产生包装类来使用
(在页面http://vckbase.com/document/viewdoc/?id=1518)

如果还有问题, 建议下载代码看看
jixingzhong 2006-09-21
  • 打赏
  • 举报
回复
http://vckbase.com/document/viewdoc/?id=1493
这个是简单组件

http://vckbase.com/document/viewdoc/?id=1518
这个是双接口组件调用
jixingzhong 2006-09-21
  • 打赏
  • 举报
回复
使用 COM 组件方式调用你的函数就可以了 ~

我给你找篇 VC 调用 COM 的例子 ...
tailzhou 2006-09-21
  • 打赏
  • 举报
回复
capicom.dll是com组件来的。
wtucel 2006-09-21
  • 打赏
  • 举报
回复
谢谢Arthur_(简单)

capicom.dll这个组件在windows2K和windows2K3里都有,用来数字签名的,我在msdn上找到个关于该组件的使用范例,不过没法下载,要windows正版用户才能下载,唉~~~没钱买正版啊
加载更多回复(1)

70,022

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧