public static void Sign(string filename) { FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.None); SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider(); byte[] hash = sha1.ComputeHash(fs); fs.Close(); byte[] b = Secure.Sign(hash); FileInfo fi = new FileInfo(filename); string dstfile = fi.DirectoryName + @"\setup.ipk"; fi.CopyTo(dstfile, true); FileStream fo = new FileStream(dstfile, FileMode.Append, FileAccess.Write, FileShare.None); fo.Write(b, 0, b.Length); fo.Close(); }
static int Main(string[] args) { try { if (args == null || args.Length == 0) { throw new Exception("Usage: ZForge.SA.Tools.Sig.exe <zipfile>"); } Secure.Sign(args[0]); Console.WriteLine("sign ok"); return(0); //Console.WriteLine(args[0]); //Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadKey(); return(1); } }