Archive for March, 2007

AES加密算法的简单封装

by Charry

AES加密算法每次对16字节的数据进行加密,而且加密后的密文通常是非ASCII字符,不易于保存和传输, 为了使用方便,我写了个包装类,使得使用AES加密非常简单,并且加密后的密文以它的16进制的形式出现,不再有乱码。

接口为:

BOOL Encrypt(const CString &key, const CString &in, CString &out);
BOOL Decrypt(const CString &key, const CString &in, CString &out);

由于AES是每16字节加密一下,所以如果被加密的明文的长度不是16的整数倍,我们需要在明文的后面补齐,比如用字符“0”。为了记录最后补了多少个“0”,可以把这个数字保存在最终的密文的后面,形如:

“DA7C8E7BF333EE0C612A8E211B139D4D{[]}10″

数字10前面的{[]}是为了查找方便。这个外包类只是我为了自己使用方便而写,其核心部分来自CodeProject:http://www.codeproject.com/cpp/aes.asp ,我只是简化了接口,并添加了UNICODE支持等细节。

点击这里下载代码

Observer设计模式之软件语言的动态切换

随着网络的普及,软件的国际化问题,越来越值得让软件作者们多花些时间去思考。下面结合Observer模式,给出一个简单的多语言切换的例子。

Read the rest of this entry »

Java中发送结构体

最近给个朋友做个网站的客户端,使用C/S模式,Client为VC6开发,Server为Java,通过Socket通信。由于Client这边为C++,所以,在接受Java发过来的数据包时,需要知道发来的包的长度,所以,就要引入变长包的机制。

方法是:首先Server发送一个包头,如下:

// packet head
typedef struct tagPacketHead{
long PacketID;
long PacketLen;
}PacketHead;

Read the rest of this entry »

MS Soap Toolkit In C++

下面的例子简要的说明一下如何使用MS Soap Toolkit访问Web Service

首先


#import “msxml3.dll”
#import “C:Program FilesCommon FilesMSSoapBinariesmssoap30.dll”
exclude(“IStream”, “ISequentialStream”, “_LARGE_INTEGER”,
“_ULARGE_INTEGER”, “tagSTATSTG”, “_FILETIME”)


Read the rest of this entry »

Nine ways to ace an interview and get the job

A post from Yahoo! finance , http://finance.yahoo.com/expert/article/careerist/26522

A good way to think about the process of getting a job is that a resume gets you in the door, and an interview is where you close the deal.

Here are nine ways to ace an interview and get the job:

Read the rest of this entry »

Where could you find freebie?

I’ve created a blog http://FreebieForYou.blogspot.com, Actually, hah, It’s a mirror site of … :) . I’ll publish more free resources there, if you need some freebie, don’t Google any more, just visit Freebie For You

Tips about sending message via bluetooth

If you got a cellphone with bluetooth like Nokia 6681, As you know, by default, N6681 doesn’t supporting sending msg directly. Below is the tip about how to send message via bluetooth.

Firstly you should run the Calendar application and create a new entry, then type whatever you want in Subject. When the new entry is saved, just highlight this entry and select ‘Send->Via Bluetooth’ in Option menu, that will invoke bluetooth. the following steps are straight-forward, select a user and send it. ah, see, you don’t need to install any messaging software, the cellphone can do it, I’ve tested it on Nokia 6681 and Nokia 6111.

一个虚拟目录配置多个站点的方法

新买的域名: googlestop.com和 www.googlestop.com指向同一个IP(呵呵,由Sakse赞助:), 如果使用虚拟主机技术,可以很方便的配置两个完全不同的站点来,但是两个站点共用一个虚拟主机,也就是说,共有一个目录,如果要实现’看上去是两个站点’的目的,可以用rewrite技术,方法如下:

Read the rest of this entry »

Switch to our mobile site