免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 8961 | 回复: 7
打印 上一主题 下一主题

字符串的加密与解密的源代码 [复制链接]

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-06-23 13:52 |只看该作者 |倒序浏览
代码一

  1. #include "windows.h"
  2. #include "stdio.h"
  3. #include "zlib.h"

  4. #define ZIPCPZ_BUFFER 32768
  5. static char tmp_in[ZIPCPZ_BUFFER];
  6. static char tmp_out[ZIPCPZ_BUFFER];
  7. static z_stream stream;

  8. static int in_length=0;
  9. static int out_length=0;

  10. int ZIPCpzInit(int Level=Z_DEFAULT_COMPRESSION)
  11. {
  12. int err;
  13. stream.next_in = (Bytef*)tmp_in;
  14. stream.avail_in = (uInt)in_length;

  15. stream.next_out = (Bytef*)tmp_out;
  16. stream.avail_out = ZIPCPZ_BUFFER;

  17. stream.zalloc = (alloc_func)0;
  18. stream.zfree = (free_func)0;
  19. stream.opaque = (voidpf)0;

  20. err = deflateInit(&stream, Level);

  21. if (err != Z_OK) return err;

  22. return Z_OK;
  23. }

  24. int ZIPCpz (LPCSTR src,DWORD src_length,FILE *fp,int bFlush=0)
  25. {
  26. int err;
  27. DWORD offset=0;

  28. if( src_length >; 0 ) //make sure input stream is available
  29. while(1)
  30. {
  31. int rLen,wLen;

  32. if( src_length + in_length >;= ZIPCPZ_BUFFER )
  33. {
  34. //buffer a block of input stream to tmp_in if it's big enough
  35. rLen=ZIPCPZ_BUFFER-in_length;

  36. memcpy(&tmp_in[in_length],src+offset,rLen);
  37. src_length -= rLen;
  38. in_length += rLen;
  39. offset+=rLen;

  40. { //zip tmp_in
  41. stream.next_in = (Bytef*)tmp_in;
  42. stream.avail_in = (uInt)in_length;

  43. stream.next_out = (Bytef*)(tmp_out+out_length);
  44. stream.avail_out = ZIPCPZ_BUFFER-out_length;

  45. while(1)
  46. {
  47. wLen=ZIPCPZ_BUFFER-out_length;

  48. err = deflate(&stream, Z_NO_FLUSH);
  49. wLen -= stream.avail_out;

  50. if(err ==Z_OK)
  51. {
  52. if( (stream.avail_out!=0) ) //cpz finished
  53. {
  54. out_length+=wLen;
  55. break;
  56. }
  57. else
  58. { // out buffer full
  59. fwrite(tmp_out,1,ZIPCPZ_BUFFER,fp);
  60. out_length=0;
  61. stream.next_out = (Bytef*)tmp_out;
  62. stream.avail_out = ZIPCPZ_BUFFER;
  63. }
  64. }
  65. else
  66. {
  67. //error ~~~~~~~~~~~
  68. printf("Error!\n");
  69. printf("Error no %d\n",err);

  70. }
  71. }

  72. in_length=0;
  73. }
  74. }
  75. else
  76. {
  77. // buffer whole input stream to tmp_in if it's not big enough
  78. // then wait for next call to fill tmp_in
  79. memcpy(&tmp_in[in_length],src+offset,src_length);
  80. in_length+=src_length;
  81. break;
  82. }
  83. }//write ok;

  84. if(bFlush)
  85. {
  86. if(in_length>;0)
  87. {
  88. stream.next_in = (Bytef*)tmp_in;
  89. stream.avail_in = (uInt)in_length;

  90. stream.next_out = (Bytef*)(tmp_out+out_length);
  91. stream.avail_out = ZIPCPZ_BUFFER-out_length;

  92. while(1)
  93. {
  94. DWORD wLen=ZIPCPZ_BUFFER-out_length;

  95. err = deflate(&stream, Z_FINISH);
  96. wLen -= stream.avail_out;

  97. if(err ==Z_STREAM_END)
  98. {
  99. if( (stream.avail_out!=0) ) //cpz finished
  100. {
  101. out_length+=wLen;
  102. break;
  103. }
  104. }
  105. else
  106. {
  107. if( err== Z_OK)
  108. {
  109. // out buffer full
  110. fwrite(tmp_out,1,ZIPCPZ_BUFFER,fp);
  111. out_length=0;
  112. stream.next_out = (Bytef*)tmp_out;
  113. stream.avail_out = ZIPCPZ_BUFFER;
  114. }
  115. else
  116. {
  117. //error ~~~~~~~~~~~
  118. printf("Error while end z file!\n");
  119. printf("Error no %d\n",err);
  120. break;
  121. }
  122. }
  123. }
  124. }

  125. fwrite(tmp_out,1,out_length,fp);
  126. in_length=0;
  127. out_length=0;
  128. }

  129. return Z_OK;
  130. }

  131. int ZIPCpzFinal()
  132. {
  133. int err;
  134. err = deflateEnd(&stream);
  135. return err;

  136. }


  137. int ZEXPORT uncompress (
  138. Bytef *dest,
  139. uLongf *destLen,
  140. const Bytef *source,
  141. uLong sourceLen)
  142. {
  143. z_stream stream;
  144. int err;

  145. stream.next_in = (Bytef*)source;
  146. stream.avail_in = (uInt)sourceLen;

  147. stream.next_out = dest;
  148. stream.avail_out = (uInt)*destLen;
  149. if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;

  150. stream.zalloc = (alloc_func)0;
  151. stream.zfree = (free_func)0;

  152. err = inflateInit(&stream);
  153. if (err != Z_OK) return err;

  154. err = inflate(&stream, Z_FINISH);
  155. if (err != Z_STREAM_END) {
  156. inflateEnd(&stream);
  157. return err == Z_OK ? Z_BUF_ERROR : err;
  158. }
  159. *destLen = stream.total_out;

  160. err = inflateEnd(&stream);
  161. return err;
  162. }


  163. void main()
  164. {

  165. printf("Zlib Version %s !\n",zlibVersion());
  166. /*char *pByte=new char[1024*1024];
  167. for(int i=0;i<1024*1024;i++)
  168. {
  169. pByte[i]=i;
  170. }
  171. ZIPCpz(pByte,1024*1024,"b.z");*/
  172. long length;
  173. FILE* fp=fopen("a.bin","rb");
  174. fseek(fp,0,SEEK_END);
  175. length=ftell(fp);
  176. fseek(fp,0,SEEK_SET);

  177. char *pByte=new char[length];
  178. FILE* fp1=fopen("b.z","wb");

  179. fread(pByte,1,length,fp);
  180. ZIPCpzInit();

  181. ZIPCpz(pByte,length>;>;1,fp1);
  182. ZIPCpz(pByte+(length>;>;1),length-(length>;>;1),fp1);

  183. ZIPCpz(0,0,fp1,1);
  184. fclose(fp1);

  185. ZIPCpzFinal();

  186. fclose(fp);

  187. printf("Add ok!\n");

  188. delete pByte;


  189. FILE* fp2=fopen("b.z","rb");

  190. fseek(fp2,0,SEEK_END);
  191. length=ftell(fp2);
  192. fseek(fp2,0,SEEK_SET);

  193. pByte=new char[length];

  194. fread(pByte,length,1,fp2);
  195. fclose(fp2);

  196. fp2=fopen("c.bin","wb");

  197. LPSTR pByte1=new char[1024*1024*25];
  198. DWORD length1=1024*1024*25;
  199. uncompress((Bytef*)pByte1,&length1,(Bytef*)pByte,length);
  200. fwrite(pByte1,1,length1,fp2);
  201. fclose(fp2);

  202. }
复制代码

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
2 [报告]
发表于 2003-06-23 13:54 |只看该作者

字符串的加密与解密的源代码

代码二

  1. RLE算法
  2. CRLECompressioin rle;
  3. char src[] = "11122233333336666666666666666666666666666666666666666666";
  4. char dest[100];
  5. char dest1[100];
  6. memset(dest, 0, 100);
  7. memset(dest1, 0, 100);
  8. int len = strlen(src);
  9. int rc = rle.Compress((unsigned char*)src, len, (unsigned char*)dest);
  10. int rc1 = rle.Decompress((unsigned char*)dest, rc, (unsigned char*)dest1);
  11. /////////////////////////////////////////////////////////////////////////////

  12. class CRLECompressioin  
  13. {
  14. public:
  15. CRLECompressioin();
  16. virtual ~CRLECompressioin();

  17. int Compress(unsigned char* src, int len, unsigned char* dest);
  18. int Decompress(unsigned char* src, int len, unsigned char* dest);
  19. };

  20. // RLECompressioin.cpp: implementation of the CRLECompressioin class.
  21. //
  22. //////////////////////////////////////////////////////////////////////

  23. #include "Compress.h"

  24. const unsigned char DELIM = (char)0xFF;
  25. const unsigned char MAX  = (char)0xFE;

  26. //////////////////////////////////////////////////////////////////////
  27. // Construction/Destruction
  28. //////////////////////////////////////////////////////////////////////

  29. CRLECompressioin::CRLECompressioin()
  30. {

  31. }

  32. CRLECompressioin::~CRLECompressioin()
  33. {

  34. }

  35. int CRLECompressioin:: Compress(unsigned char* src, int len, unsigned char* dest)
  36. {
  37. unsigned char current_char;
  38. int  char_count = 0;

  39. int iCompressedLen = 0;

  40. for(int iLoop = 0; iLoop < len; iLoop++)
  41. {
  42. if((src[iLoop] == src[iLoop + 1]) && (src[iLoop] == src[iLoop + 2]))
  43. {
  44. current_char = src[iLoop];
  45. char_count = 0x00;
  46. bool hit_end = false;
  47. for(int iLoop2 = 0; iLoop2 < 0xFE; iLoop2++)
  48. {
  49. if(src[iLoop + iLoop2] == current_char)
  50. {
  51. char_count++;
  52. }
  53. else
  54. {
  55. iLoop += (char_count - 1);
  56. dest[iCompressedLen++] = DELIM;
  57. dest[iCompressedLen++] = char_count;
  58. dest[iCompressedLen++] = current_char;
  59. iLoop2 = 0xFE;
  60. hit_end = true;
  61. }
  62. }
  63. if(!hit_end)
  64. {
  65. iLoop += 0xFD;
  66. dest[iCompressedLen++] = DELIM;
  67. dest[iCompressedLen++] = MAX;
  68. dest[iCompressedLen++] = current_char;
  69. }
  70. }
  71. else
  72. {
  73. if(src[iLoop] == DELIM)
  74. {
  75. dest[iCompressedLen++] = DELIM;
  76. dest[iCompressedLen++] = DELIM;
  77. }
  78. else
  79. {
  80. dest[iCompressedLen++] = src[iLoop];
  81. }
  82. }
  83. }

  84. return iCompressedLen;

  85. }

  86. int CRLECompressioin::Decompress(unsigned char* src, int len, unsigned char* dest)
  87. {

  88. int iDecompressedLen = 0;

  89. for(int iLoop = 0; iLoop < len; iLoop++)
  90. {
  91. if(src[iLoop] == DELIM)
  92. {
  93. if(src[iLoop + 1] == DELIM)
  94. {
  95. dest[iDecompressedLen++] = src[iLoop];
  96. iLoop++;
  97. }
  98. else
  99. {
  100. int iBufSize = (int)src[iLoop + 1];
  101. for(int iLoop2 = 0; iLoop2 < iBufSize; iLoop2++)
  102. {
  103. dest[iDecompressedLen++] = src[iLoop+2];
  104. }
  105. iLoop += 2;
  106. }
  107. }
  108. else
  109. {
  110. dest[iDecompressedLen++] = src[iLoop];
  111. }
  112. }

  113. return iDecompressedLen;
  114. }
复制代码

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
3 [报告]
发表于 2003-06-23 13:54 |只看该作者

字符串的加密与解密的源代码

代码三

  1. 这个是LZO的压缩算法,应该很快。

  2. // LZOCompress.cpp: implementation of the CLZOCompress class.
  3. //
  4. //////////////////////////////////////////////////////////////////////

  5. #include "stdafx.h"
  6. #include "LZOCompress.h"

  7. #ifdef _DEBUG
  8. #undef THIS_FILE
  9. static char THIS_FILE[]=__FILE__;
  10. #define new DEBUG_NEW
  11. #endif

  12. //////////////////////////////////////////////////////////////////////
  13. // Construction/Destruction
  14. //////////////////////////////////////////////////////////////////////

  15. CLZOCompress::CLZOCompress()
  16. {

  17. }

  18. CLZOCompress::~CLZOCompress()
  19. {

  20. }

  21. unsigned CLZOCompress::_do_compress (byte *in,
  22. unsigned in_len,
  23. byte *out,
  24. unsigned *out_len)
  25. {
  26. static long wrkmem [16384L];
  27.     register byte *ip;
  28.     byte *op;
  29. byte *in_end = in + in_len;
  30.     byte *ip_end = in + in_len - 13;
  31.     byte *ii;
  32.     byte **dict = (byte **)wrkmem;
  33.     op = out;
  34. ip = in;
  35. ii = ip;
  36.     ip += 4;
  37.     for(;;)
  38. {
  39. register byte *m_pos;
  40. unsigned m_off;
  41. unsigned m_len;
  42. unsigned dindex;
  43. dindex = ((0x21*(((((((unsigned)(ip[3])<<6)^ip[2])<<5)^ip[1])<<5)^ip[0]))>;>;5) & 0x3fff;
  44. m_pos = dict [dindex];
  45. if(((unsigned)m_pos < (unsigned)in) ||
  46. (m_off = (unsigned)((unsigned)ip-(unsigned)m_pos) ) <= 0 ||
  47. m_off >; 0xbfff)
  48. goto literal;
  49. if(m_off <= 0x0800 || m_pos[3] == ip[3])
  50. goto try_match;
  51. dindex = (dindex & 0x7ff ) ^ 0x201f;
  52. m_pos = dict[dindex];
  53. if((unsigned)(m_pos) < (unsigned)(in) ||
  54. (m_off = (unsigned)( (int)((unsigned)ip-(unsigned)m_pos))) <= 0 ||
  55. m_off >; 0xbfff)
  56. goto literal;
  57. if (m_off <= 0x0800 || m_pos[3] == ip[3])
  58. goto try_match;
  59. goto literal;
  60. try_match:
  61. if(*(unsigned short*)m_pos == *(unsigned short*)ip && m_pos[2]==ip[2])
  62. goto match;
  63. literal:
  64. dict[dindex] = ip;
  65. ++ip;
  66. if (ip >;= ip_end)
  67. break;
  68. continue;
  69. match:
  70. dict[dindex] = ip;
  71. if(ip - ii >; 0)
  72. {
  73. register unsigned t = ip - ii;

  74. if (t <= 3)
  75. op[-2] |= (byte)t;
  76. else if(t <= 18)
  77. *op++ = (byte)(t - 3);
  78. else
  79. {
  80. register unsigned tt = t - 18;
  81. *op++ = 0;
  82. while(tt >; 255)
  83. {
  84. tt -= 255;
  85. *op++ = 0;
  86. }
  87. *op++ = (byte)tt;
  88. }
  89. do *op++ = *ii++; while (--t >; 0);
  90. }
  91. ip += 3;
  92. if(m_pos[3] != *ip++ || m_pos[4] != *ip++ || m_pos[5] != *ip++ ||
  93. m_pos[6] != *ip++ || m_pos[7] != *ip++ || m_pos[8] != *ip++ )
  94. {
  95. --ip;
  96. m_len = ip - ii;

  97. if(m_off <= 0x0800 )
  98. {
  99. --m_off;
  100. *op++ = (byte)(((m_len - 1) << 5) | ((m_off & 7) << 2));
  101. *op++ = (byte)(m_off >;>; 3);
  102. }
  103. else
  104. if (m_off <= 0x4000 )
  105. {
  106. -- m_off;
  107. *op++ = (byte)(32 | (m_len - 2));
  108. goto m3_m4_offset;
  109. }
  110. else
  111. {
  112. m_off -= 0x4000;
  113. *op++ = (byte)(16 | ((m_off & 0x4000) >;>; 11) | (m_len - 2));
  114. goto m3_m4_offset;
  115. }
  116. }
  117. else
  118. {
  119. {
  120. byte *end = in_end;
  121. byte *m = m_pos + 9;
  122. while (ip < end && *m == *ip)
  123. m++, ip++;
  124. m_len = (ip - ii);
  125. }

  126. if(m_off <= 0x4000)
  127. {
  128. --m_off;
  129. if (m_len <= 33)
  130. *op++ = (byte)(32 | (m_len - 2));
  131. else
  132. {
  133. m_len -= 33;
  134. *op++=32;
  135. goto m3_m4_len;
  136. }
  137. }
  138. else
  139. {
  140. m_off -= 0x4000;
  141. if(m_len <= 9)
  142. *op++ = (byte)(16|((m_off & 0x4000) >;>; 11) | (m_len - 2));
  143. else
  144. {
  145. m_len -= 9;
  146. *op++ = (byte)(16 | ((m_off & 0x4000) >;>; 11));
  147. m3_m4_len:
  148. while (m_len >; 255)
  149. {
  150. m_len -= 255;
  151. *op++ = 0;
  152. }
  153. *op++ = (byte)m_len;
  154. }
  155. }
  156. m3_m4_offset:
  157. *op++ = (byte)((m_off & 63) << 2);
  158. *op++ = (byte)(m_off >;>; 6);
  159. }
  160. ii = ip;
  161. if (ip >;= ip_end)
  162. break;
  163.     }
  164.     *out_len = op - out;
  165.     return (unsigned) (in_end - ii);
  166. }

  167. int _stdcall CLZOCompress::compress(void *in, unsigned in_len,
  168.   void *out)
  169. {
  170.     byte *op = (unsigned char*)out;
  171.     unsigned t,out_len;
  172.     if (in_len <= 13)
  173. t = in_len;
  174.     else
  175. {
  176. t = CLZOCompress::_do_compress ((unsigned char*)in,in_len,op,&out_len);
  177. op += out_len;
  178.     }
  179.     if (t >; 0)
  180. {
  181. byte *ii = (byte*)in + in_len - t;
  182. if (op == (byte*)out && t <= 238)
  183. *op++ = (byte) ( 17 + t );
  184. else
  185. if (t <= 3)
  186. op[-2] |= (byte)t ;
  187. else
  188. if (t <= 18)
  189. *op++ = (byte)(t-3);
  190. else
  191. {
  192. unsigned tt = t - 18;
  193. *op++ = 0;
  194. while (tt >; 255)
  195. {
  196. tt -= 255;
  197. *op++ = 0;
  198. }
  199. *op++ = (byte)tt;
  200. }
  201. do *op++ = *ii++; while (--t >; 0);
  202.     }
  203.     *op++ = 17;
  204.     *op++ = 0;
  205.     *op++ = 0;
  206.     return (op - (byte*)out);
  207. }

  208. int _stdcall CLZOCompress::decompress (void *in, unsigned in_len,
  209. void *out)
  210. {
  211.     register byte *op;
  212.     register byte *ip;
  213.     register unsigned t;
  214.     register byte *m_pos;
  215.     byte *ip_end = (byte*)in + in_len;
  216.     op = (unsigned char*)out;
  217.     ip = (unsigned char*)in;
  218.     if(*ip >; 17)
  219. {
  220. t = *ip++ - 17;
  221. if (t < 4)
  222. goto match_next;
  223. do *op++ = *ip++; while (--t >; 0);
  224. goto first_literal_run;
  225.     }
  226.     for(;;)
  227. {
  228. t = *ip++;
  229. if (t >;= 16) goto match;
  230. if (t == 0)
  231. {
  232. while (*ip == 0)
  233. {
  234. t += 255;
  235. ip++;
  236. }
  237. t += 15 + *ip++;
  238. }
  239. * (unsigned *) op = * ( unsigned *) ip;
  240. op += 4; ip += 4;
  241. if (--t >; 0)
  242. {
  243. if (t >;= 4)
  244. {
  245. do
  246. {
  247. * (unsigned * ) op = * ( unsigned * ) ip;
  248. op += 4; ip += 4; t -= 4;
  249. } while (t >;= 4);
  250. if (t >; 0) do *op++ = *ip++; while (--t >; 0);
  251. }
  252. else
  253. do *op++ = *ip++; while (--t >; 0);
  254. }
  255. first_literal_run:
  256. t = *ip++;
  257. if (t >;= 16)
  258. goto match;
  259. m_pos = op - 0x0801;
  260. m_pos -= t >;>; 2;
  261. m_pos -= *ip++ << 2;
  262. *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos;
  263. goto match_done;
  264. for(;;)
  265. {
  266. match:
  267. if (t >;= 64)
  268. {
  269. m_pos = op - 1;
  270. m_pos -= (t >;>; 2) & 7;
  271. m_pos -= *ip++ << 3;
  272. t = (t >;>; 5) - 1;
  273. goto copy_match;
  274. }
  275. else
  276. if (t >;= 32)
  277. {
  278. t &= 31;
  279. if (t == 0)
  280. {
  281. while (*ip == 0)
  282. {
  283. t += 255;
  284. ip++;
  285. }
  286. t += 31 + *ip++;
  287. }
  288. m_pos = op - 1;
  289. m_pos -= (* ( unsigned short * ) ip) >;>; 2;
  290. ip += 2;
  291. }
  292. else
  293. if (t >;= 16)
  294. {
  295. m_pos = op;
  296. m_pos -= (t & 8) << 11;
  297. t &= 7;
  298. if (t == 0)
  299. {
  300. while (*ip == 0)
  301. {
  302. t += 255;
  303. ip++;
  304. }
  305. t += 7 + *ip++;
  306. }
  307. m_pos -= (* ( unsigned short *) ip) >;>; 2;
  308. ip += 2;
  309. if (m_pos == op)
  310. goto eof_found;
  311. m_pos -= 0x4000;
  312. }
  313. else
  314. {
  315. m_pos = op - 1;
  316. m_pos -= t >;>; 2;
  317. m_pos -= *ip++ << 2;
  318. *op++ = *m_pos++; *op++ = *m_pos;
  319. goto match_done;
  320. }
  321. if (t >;= 6 && (op - m_pos) >;= 4)
  322. {
  323. * (unsigned *) op = * ( unsigned *) m_pos;
  324. op += 4; m_pos += 4; t -= 2;
  325. do
  326. {
  327. * (unsigned *) op = * ( unsigned *) m_pos;
  328. op += 4; m_pos += 4; t -= 4;
  329. }while (t >;= 4);
  330. if (t >; 0)
  331. do *op++ = *m_pos++; while (--t >; 0);
  332. }
  333. else
  334. {
  335. copy_match:
  336. *op++ = *m_pos++; *op++ = *m_pos++;
  337. do *op++ = *m_pos++; while (--t >; 0);
  338. }
  339. match_done:
  340. t = ip[-2] & 3;
  341. if (t == 0) break;
  342. match_next:
  343. do *op++ = *ip++; while (--t >; 0);
  344. t = *ip++;
  345. }
  346.   }
  347. eof_found:
  348.   if (ip != ip_end) return -1;
  349.   return (op - (byte*)out);
  350. }

复制代码

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
4 [报告]
发表于 2003-06-23 14:07 |只看该作者

字符串的加密与解密的源代码

穷举密码算法

  1. void createpassword()
  2. {
  3. #define passwordmax 8 //将生成密码的最大长度

  4. char a[]="0123456789abcdefghijklmnopqrstuvwxyz"; //可能的字符
  5. long ndictcount=sizeof(a); //获得密码词典长度
  6. char cpass[passwordmax+2]; //将生成的密码
  7. long nminl=1,nmaxl=3; //本例中密码长度从1-3
  8. long array[passwordmax]; //密码词典下标

  9. assert(nminl<=nmaxl && nmaxl<=passwordmax);//容错保证
  10. long nlength=nminl;
  11. register long j,i=0;
  12. bool bnext;
  13. cstdiofile file;
  14. file.open("c:\\dict.txt",cfile::modecreate|cfile::modewrite);
  15. while(nlength<=nmaxl)
  16. {
  17. for(i=0;i<passwordmax;i++)
  18. array[i]=0;
  19. bnext=true;
  20. while(bnext)
  21. {
  22. for(i=0;i<nlength;i++)
  23. cpass[i]=a[array[i]];
  24. cpass[i]='\0';
  25. file.writestring(cpass);
  26. file.writestring("\n");
  27. for(j=nlength-1;j>;=0;j--) //密码指针进位
  28. {
  29. array[j]++;
  30. if(array[j]!=ndictcount-1)break;
  31. else
  32. {
  33. array[j]=0;
  34. if(j==0)bnext=false;
  35. }
  36. }

  37. }
  38. nlength++;
  39. }
  40. file.close();
  41. }

复制代码

论坛徽章:
0
5 [报告]
发表于 2003-06-23 14:11 |只看该作者

字符串的加密与解密的源代码

高人!

论坛徽章:
0
6 [报告]
发表于 2003-06-23 22:31 |只看该作者

字符串的加密与解密的源代码

我看Morris的worm程序里有加密的字符串,只是不会用,估计一般也不用吧

论坛徽章:
0
7 [报告]
发表于 2003-06-24 00:57 |只看该作者

字符串的加密与解密的源代码

键盘兄,有标准des加密解密算法吗?

论坛徽章:
0
8 [报告]
发表于 2003-06-24 01:00 |只看该作者

字符串的加密与解密的源代码

精华中有过介绍吧
很久以前的
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP