Advertisement
adilima

DCP Hash Checker Using C#

Dec 6th, 2017
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Text;
  4. using System.Security.Cryptography;
  5.  
  6. /**
  7.  * This one is SHA1 Checker, the one I use to verify DCP PackingList
  8.  * You can use it (or modify it) freely to meet your own needs.
  9.  *
  10.  * Usually tools like EasyDCP only load PKL_*.xml to search for main
  11.  * mxf files, plus another XML starting with CPL_.
  12.  *
  13.  * Computing SHA1 for those mxf is the longest process, so it won't hurt
  14.  * even if we compute all files refer to by the PKL.
  15.  *
  16.  * Unlike MD5, SHA1 required by DCP uses base64 encoding string,
  17.  * so we must use the following call to convert the bytes returned by
  18.  * SHA1::ComputeHash().
  19.  *
  20.  * On Linux you can use a simple command like the following without
  21.  * the need for extra program like this one:
  22.  *
  23.  *    sha1sum [filename].mxf | xxd -r -p | base64
  24.  *
  25.  * But we can also use these codes with Mono and put a nice UI if you want.
  26.  * :)
  27. */
  28.  
  29. class SHATest64
  30. {
  31.     static void Main(string[] args)
  32.     {
  33.         string appName = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
  34.         if (args.Length == 0)
  35.         {
  36.             Console.WriteLine(appName + " [filename]");
  37.             return;
  38.         }
  39.         SHA1 sha = SHA1.Create();
  40.         if (File.Exists(args[0]))
  41.         {
  42.             FileStream fs = File.OpenRead(args[0]);
  43.             byte[] data = sha.ComputeHash(fs);
  44.             string strBase64 =  System.Convert.ToBase64String(data);
  45.             Console.Write("Base64 SHA1 Hash: ");
  46.             ConsoleColor fg = Console.ForegroundColor;
  47.             Console.ForegroundColor = ConsoleColor.Yellow;
  48.             Console.Write(strBase64 + "\n");
  49.             Console.ForegroundColor = fg;
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement