Develop and Download Open Source Software

Browse CVS Repository

Contents of /tombo/Tombo/Src/Crypt.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Fri Oct 4 23:56:39 2002 UTC (21 years, 6 months ago) by hirami
Branch: MAIN
CVS Tags: B118, B155, B110, B111, B113, B114, B115, B116, B117, Tombo_2_0a3, Tombo_2_0a2, Tombo_2_0a1, Tombo_1_8_1, Tombo_1_17_1, B153, B109, B108, B103, B102, B101, B100, B107, B106, B105, B104, B082, B191, B192, B193, B194, Tombo_1_9b1, B196, B197, B198, B199, B200, B201, B202, B203, B205, B206, B207, B208, B083, Tombo_1_6b2, Tombo_1_6b1, SNAPSHOT_20040920, SNAPSHOT_20040925, B183, B181, B180, B187, B186, B184, B189, B188, B079, B213, B212, B211, B217, B216, B215, B214, B219, B218, B089, SNAPSHOT_20030824, B078, Tombo_2_0b2, Tombo_2_0b3, Tombo_2_0b1, Tombo_1_9, Tombo_1_8, Tombo_2_0b4, Tombo_1_5, Tombo_1_4, Tombo_1_7, Tombo_1_6, Tombo_1_3, B068, Tombo_1_7b2, Tombo_1_7b3, Tombo_1_7b1, Tombo_1_7b4, Tombo_1_7b5, B136, B134, B135, B132, B133, B228, B229, B226, B227, B224, B225, B222, B223, B220, B221, B154, B172, B156, B157, B150, B151, B152, B173, B158, B159, B130, B171, Tombo_1_10, Tombo_1_13, SNAPSHOT20051220, Tombo_1_12, B088, B131, B121, B120, B123, B122, B125, B124, B126, B231, B230, B080, B081, B086, B087, B084, B085, B147, B146, B145, B144, B143, B142, B141, B140, B149, B148, B129, B128, Tombo_1_8b1, B095, B094, B096, B091, B090, B093, B092, B099, B098, Tombo_1_15, Tombo_1_14, Tombo_1_17, Tombo_1_16, Tombo_1_11, B177, B174, B175, B073, B072, B178, B179, B077, B076, B075, B074, B164, B071, B070, B169, B168, B165, SNAPSHOT_20041121, B166, B161, B160, B163, B162, B066, SNAPSHOT_20040314, B067, B069, B138, B139, Tombo_1_5_1, HEAD
Branch point for: Tombo_2_0alpha_branch, Tombo_1_8_1_branch, Tombo_1_7b3_branch, Tombo_1_17_1_branch, Tombo_1_5_1_branch
File MIME type: text/x-c++src
Tombo 1.3公開時のソースからビットマップ・アイコンをSrc/images下に移動したもの

1 #include <windows.h>
2 #include "Crypt.h"
3
4 extern "C" {
5 void *BF_Init(byte *key, unsigned keylen);
6 void BF_Enc(void *handle, byte *chipher, byte *plain, int len);
7 void BF_Dec(void *handle, byte *plain, byte *chipher);
8 void BF_Free(void *handle);
9 };
10
11
12 Crypt::Crypt() : handle(NULL)
13 {
14 }
15
16 Crypt::~Crypt()
17 {
18 if (handle != NULL) {
19 BF_Free(handle);
20 }
21 }
22
23 BOOL Crypt::ResetStream(byte *key, unsigned int len)
24 {
25 if (handle != NULL) {
26 BF_Free(handle);
27 handle = NULL;
28 }
29
30 handle = BF_Init(key, len);
31 if (handle == NULL) return FALSE;
32
33 return TRUE;
34 }
35
36 BOOL Crypt::Encrypt(byte *chipher, byte *plain, int len)
37 {
38 if (handle == NULL) {
39 SetLastError(ERROR_INVALID_DATA);
40 return FALSE;
41 }
42 BF_Enc(handle, chipher, plain, len);
43 return TRUE;
44 }
45
46 BOOL Crypt::Decrypt(byte *plain, byte *chipher)
47 {
48 if (handle == NULL) {
49 SetLastError(ERROR_INVALID_DATA);
50 return FALSE;
51 }
52 BF_Dec(handle, plain, chipher);
53 return TRUE;
54 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26