コード例 #1
0
 private static bool ComputeFullHash(FileInfoExt path)
 {
     try
     {
         var _SHA512 = SHA512.Create();
         _SHA512.TransformBlock(salt, 0, salt.Length, null, 0);
         using (var stream = File.OpenRead(path.FI.FullName))
         {
             while (true)
             {
                 var length = stream.Read(largeBuf, 0, largeBuf.Length);
                 if (stream.Position < stream.Length)                                    // if not at end of file...
                 {
                     _SHA512.TransformBlock(largeBuf, 0, length, null, 0);               // hash the buffer, and loop.
                 }
                 else
                 {
                     _SHA512.TransformFinalBlock(largeBuf, 0, length);                   // if at end of file, hash last time and end looping
                     break;
                 }
             }
         }
         path.SHA512_All = _SHA512.Hash;
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine("Hash error: " + e.Message);
         path.Matched = true;
         return(false);
     }
 }
コード例 #2
0
ファイル: 2345.cs プロジェクト: f0rkB0mb/poshcode.github.io
 private static bool ComputeFullHash(FileInfoExt path)
 {
     Buffer.BlockCopy(randomNumber, 0, largeBuf, 0, randomNumber.Length);
     try
     {
         var _SHA = SHA512.Create();
         using (var stream = File.OpenRead(path.FI.FullName))
         {
             System.Boolean EOF = false;
             while (EOF == false)
             {
                 var length = stream.Read(largeBuf, hash.Length, largeBuf.Length - hash.Length);
                 if (length != (largeBuf.Length - hash.Length))
                 {
                     EOF = true;
                 }
                 hash = _SHA.ComputeHash(largeBuf, 0, length + hash.Length);
                 Buffer.BlockCopy(hash, 0, largeBuf, 0, hash.Length);
             }
         }
         Buffer.BlockCopy(hash, 0, path.SHA512_All, 0, hash.Length);
         path.SHA512_AllSet = true;
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine("Hash error: " + e.Message);
         return(false);
     }
 }
コード例 #3
0
 private static bool ComputeFullHash(FileInfoExt path)
 {
     try
     {
         var _SHA512 = SHA512.Create();
         _SHA512.TransformBlock(salt, 0, salt.Length, salt, 0);
         using (var stream = File.OpenRead(path.FI.FullName))
         {
             while (true)
             {
                 var length = stream.Read(largeBuf, 0, largeBuf.Length);
                 if (stream.Position < stream.Length)
                 {
                     _SHA512.TransformBlock(largeBuf, 0, length, largeBuf, 0);
                 }
                 else
                 {
                     _SHA512.TransformFinalBlock(largeBuf, 0, length);
                     break;
                 }
             }
         }
         path.SHA512_All    = _SHA512.Hash;
         path.SHA512_AllSet = true;
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine("Hash error: " + e.Message);
         return(false);
     }
 }
コード例 #4
0
ファイル: 2428.cs プロジェクト: f0rkB0mb/poshcode.github.io
 private static bool ComputeFullHash(FileInfoExt path)
 {
     try
     {
         var _SHA512 = SHA512.Create();
         using (var fstream = File.OpenRead(path.FI.FullName))
         {
             _SHA512.ComputeHash(fstream);
         }
         path.SHA512_All = _SHA512.Hash;
         return(true);
     }
     catch (Exception e)
     {
         WriteErr("Hash error: " + e.Message);
         path.Matched = true;
         return(false);
     }
 }
コード例 #5
0
ファイル: 2345.cs プロジェクト: f0rkB0mb/poshcode.github.io
 private static bool Compute1KHash(FileInfoExt path)
 {
     Buffer.BlockCopy(randomNumber, 0, readBuf, 0, randomNumber.Length);
     try
     {
         using (var stream = File.OpenRead(path.FI.FullName))
         {
             var length = stream.Read(readBuf, hash.Length, readBuf.Length - hash.Length);
             hash = SHA512.Create().ComputeHash(readBuf, 0, length + hash.Length);
             Buffer.BlockCopy(hash, 0, path.SHA512_1st1K, 0, hash.Length);
             path.SHA512_1st1KSet = true;
             return(true);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("Hash Error: " + e.Message);
         return(false);
     }
 }
コード例 #6
0
ファイル: 2428.cs プロジェクト: f0rkB0mb/poshcode.github.io
 private static bool Compute1KHash(FileInfoExt path)
 {
     try
     {
         using (var fstream = File.OpenRead(path.FI.FullName))
         {
             var length  = fstream.Read(readBuf, 0, readBuf.Length);
             var _SHA512 = SHA512.Create();
             _SHA512.TransformFinalBlock(readBuf, 0, length);
             path.SHA512_1st1K = _SHA512.Hash;
             return(true);
         }
     }
     catch (Exception e)
     {
         WriteErr("Hash Error: " + e.Message);
         path.Matched = true;                                                            // since the file error'ed out, don't check against it again.
         return(false);
     }
 }
コード例 #7
0
 private static bool Compute1KHash(FileInfoExt path)
 {
     try
     {
         using (var stream = File.OpenRead(path.FI.FullName))
         {
             var length  = stream.Read(readBuf, 0, readBuf.Length);
             var _SHA512 = SHA512.Create();
             _SHA512.TransformBlock(salt, 0, salt.Length, salt, 0);
             _SHA512.TransformFinalBlock(readBuf, 0, length);
             path.SHA512_1st1K    = _SHA512.Hash;
             path.SHA512_1st1KSet = true;
             return(true);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("Hash Error: " + e.Message);
         return(false);
     }
 }