Esempio n. 1
0
File: CRC32.cs Progetto: sinshu/dtf
        private UInt32 Update(string FullPathToFile)
        {
            unchecked
            {
                global::System.Text.UnicodeEncoding myEncoder = new global::System.Text.UnicodeEncoding();

                // yanesdkのFileSys.GetPureFileNameを呼び出したほうがいいんだけれど…。

                int    index       = FullPathToFile.LastIndexOf(Path.DirectorySeparatorChar);
                string strFileName = FullPathToFile.Substring(index + 1);

                int    count  = myEncoder.GetByteCount(strFileName);
                byte[] buffer = new byte[count];
                buffer = myEncoder.GetBytes(strFileName);

                UInt32 crc = HighBitMask;

                for (int i = 0; i < count; i++)
                {
                    crc = ((crc) >> 8) ^ CRCTable[(buffer[i]) ^ ((crc) & 0x000000FF)];
                }

                crc          = ~crc;
                LifetimeCRC ^= crc;
                return(crc);
            }
        }
Esempio n. 2
0
        private UInt32 Update( string FullPathToFile )
        {
            unchecked
            {
                global::System.Text.UnicodeEncoding myEncoder = new global::System.Text.UnicodeEncoding();

                // yanesdkのFileSys.GetPureFileNameを呼び出したほうがいいんだけれど…。

                int index = FullPathToFile.LastIndexOf( Path.DirectorySeparatorChar );
                string strFileName = FullPathToFile.Substring( index + 1 );

                int count = myEncoder.GetByteCount( strFileName );
                byte[] buffer = new byte[count];
                buffer = myEncoder.GetBytes(strFileName);

                UInt32 crc = HighBitMask;

                for (int i = 0; i < count; i++)
                    crc = ((crc) >> 8) ^ CRCTable[(buffer[i]) ^ ((crc) & 0x000000FF)];

                crc = ~crc;
                LifetimeCRC ^= crc;
                return crc;
            }
        }