Crypt_XXTEA 0.9.0 has been released
In November the last year, I received an email which informed me that the encryption result of my Crypt_XXTEA package differs from some other implementations. And I made a reply to explain the reason.

XXTEA is a block cipher which requires the block size is at least two words, i.e. 32 bits. If the length of string is not multiples of 4, the last block must be fill up to 32 bits by some junk data. Thus the decrypted string will have the junk data at its end too. To solve this problem, the initial version of Crypt_XXTEA appends the length of string to the end of the converted long integer array, which can be used to cut the decrypted string to get the correct result.

Rencently, considered that this default behavior may confuse the user, I made some modifications. In the version of 0.9.0, users can handle the converting between string and long integer array with their own functions.

Link: http://pear.php.net/package/Crypt_XXTEA
Current language: English · also available in: Chinese (Simplified)
Thunderbird vs Becky!
Becky! 用了近 3 年了。但为了将来用 Linux 做准备,上次部分硬盘数据(包括邮件)丢失后,想用 Thunderbird 作邮件客户端。

用了一段时间 Thunderbird,发现了很多问题(和 Becky! 比较)。最不能忍受的就是附件无法单独存储,而是邮件内容存放到一起,编辑或查看带有附件的邮件时速度十分缓慢。剩下的就是整体上功能相比 Becky! 弱很多。现在感觉 Thunderbird 和 Becky! 相比优点主要是它的 Webmail 插件收发 Hotmail 邮件比 Becky! 里的 Hotmail 插件好很多,Enigmail 也比 Becky! 里那个 PGP 插件做得好。
Current language: Chinese (Simplified)
A simple class that reads UTF-8 or GBK encoding text file
  1. public static class TextFileReader
  2. {
  3.     public static string ReadFile(string path)
  4.     {
  5.         FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read,
  6.                             FileShare.Read, 8192, FileOptions.SequentialScan);
  7.         return ReadStream(stream);
  8.     }
  9.  
  10.     public static string ReadStream(Stream stream)
  11.     {
  12.         byte[] bytes = new byte[stream.Length];
  13.         long length = (stream.Length > 8192) ? (long)8192 : stream.Length;
  14.         byte first;
  15.         long pos = 0;
  16.         bool is_utf8 = true;
  17.         while (pos < length)
  18.         {
  19.             first = bytes[pos++] = (byte)stream.ReadByte();
  20.             if (first < 192)
  21.             {
  22.             }
  23.             else if (first < 224)
  24.             {
  25.                 if ((length - pos > 1) &&
  26.                     (bytes[pos++] = (byte)stream.ReadByte()) < 128)
  27.                 {
  28.                     is_utf8 = false;
  29.                     break;
  30.                 }
  31.             }
  32.             else if (first < 240)
  33.             {
  34.                 if ((length - pos > 2) &&
  35.                     !((bytes[pos++] = (byte)stream.ReadByte()) > 127
  36.                     && (bytes[pos++] = (byte)stream.ReadByte()) > 127))
  37.                 {
  38.                     is_utf8 = false;
  39.                     break;
  40.                 }
  41.             }
  42.             else
  43.             {
  44.                 if ((length - pos > 3) &&
  45.                     !((bytes[pos++] = (byte)stream.ReadByte()) > 127
  46.                     && (bytes[pos++] = (byte)stream.ReadByte()) > 127
  47.                     && (bytes[pos++] = (byte)stream.ReadByte()) > 127))
  48.                 {
  49.                     is_utf8 = false;
  50.                     break;
  51.                 }
  52.             }
  53.         }
  54.         if (pos < stream.Length)
  55.         {
  56.             stream.Read(bytes, (int)pos, (int)(stream.Length - pos));
  57.         }
  58.         if (is_utf8)
  59.         {
  60.             return Encoding.UTF8.GetString(bytes);
  61.         }
  62.         else
  63.         {
  64.             return Encoding.Default.GetString(bytes);
  65.         }
  66.     }
  67. }
Current language: English · also available in: Chinese (Simplified)
我也有今天~~
以前只是经常听到周围的同学说起数据丢失的遭遇,没想到今天轮到我了。引起他们数据丢失的原因基本都是误操作和被他人破坏。而我的电脑只有我一个人用,而且我没有删文件的习惯。这次问题依然是――硬盘损坏。
这是第二块损坏的硬盘了,和第一块不同,第二块是机械故障,数据估计很难找回来了〔专业恢复太贵,那些数据还没那么值钱〕。
Current language: Chinese (Simplified)
MonoTorrent
MonoTorrent - A BitTorrent Library for .NET
Current language: Chinese (Simplified)
More entries: [1] [2] [3] [4] [5] [6] [7] [8] ... [16]
« Previous page · Next page »