public static void InitCheckSum() { #if BLIT return; //everything's fine. #else try { var checkSumFile = Path.Combine(MyFileSystem.ContentPath, "checksum.xml"); if (!File.Exists(checkSumFile)) { MySandboxGame.Log.WriteLine("Checksum file is missing, game will run as usual but file integrity won't be verified"); } else { using (var stream = File.OpenRead(checkSumFile)) { XmlSerializer serializer = new XmlSerializer(typeof(MyChecksums)); var checksums = (MyChecksums)serializer.Deserialize(stream); var verifier = new MyChecksumVerifier(checksums, MyFileSystem.ContentPath); verifier.ChecksumFailed += ChecksumFailed; verifier.ChecksumNotFound += ChecksumNotFound; stream.Position = 0; var p = MySHA256.Create(); p.Initialize(); var hash = p.ComputeHash(stream); string expectedKey = "BgIAAACkAABSU0ExAAQAAAEAAQClSibD83Y6Akok8tAtkbMz4IpueWFra0QkkKcodwe2pV/RJAfyq5mLUGsF3JdTdu3VWn93VM+ZpL9CcMKS8HaaHmBZJn7k2yxNvU4SD+8PhiZ87iPqpkN2V+rz9nyPWTHDTgadYMmenKk2r7w4oYOooo5WXdkTVjAD50MroAONuQ=="; MySandboxGame.Log.WriteLine("Checksum file hash: " + Convert.ToBase64String(hash)); MySandboxGame.Log.WriteLine(string.Format("Checksum public key valid: {0}, Key: {1}", checksums.PublicKey == expectedKey, checksums.PublicKey)); MyFileSystem.FileVerifier = verifier; } } } catch { } #endif }
public MyRSA() { m_hasher = MySHA256.Create(); m_hasher.Initialize(); }