Forum » Izdelava spletišč » Dump MaCoFaCove kode za hash
Dump MaCoFaCove kode za hash
BluPhenix ::
Pomen:
Algoritem:
00 .................................. rezervirano (1 B) 0f95 ................................ video traja 3989 sekund (2 B) 00002bbcc000 ........................ datoteka je dolga 733.790.208 B (6 B) 18d5d8c1747b005aaa2800a18e81de97 .... MD5 hash (16 B) 11 .................................. kontrolni bajt (1 B)
Algoritem:
/// <summary> /// C# algorithm which computes hash of video file. Computed hash is then used to find matching subtitles. /// </summary> /// <param name="filePath">Absolute path to video file.</param> /// <returns>Computed hash value formated as hexadecimal string (52 characters). Returns null on failure.</returns> public static string Compute(string filePath) { try { if (!System.IO.File.Exists(filePath)) { return null; } List<byte> hash = new List<byte>(26); //0: reserved hash.Insert(0, 0x0); //1-2: video length in seconds short runTime = new VideoInfo(filePath).RunTime; if (BitConverter.IsLittleEndian) { hash.InsertRange(1, Invert(BitConverter.GetBytes(runTime))); } else { hash.InsertRange(1, BitConverter.GetBytes(runTime)); } //3-8: file length in bytes long fileLength = new FileInfo(filePath).Length; if (BitConverter.IsLittleEndian) { hash.InsertRange(3, GetLastBytes(Invert(BitConverter.GetBytes(fileLength)), 6)); } else { hash.InsertRange(3, GetLastBytes(BitConverter.GetBytes(fileLength), 6)); } //9-24: MD5 hash for first 5 MB of file hash.InsertRange(9, ComputeMD5FromFile(filePath, 5 * 1024 * 1024)); //25: control byte int sum = 0; for (int i = 0; i < 25; i++) { sum += hash[i]; } hash.Insert(25, Convert.ToByte(sum % 256)); //convert to hex string StringBuilder sbResult = new StringBuilder(); for (int i = 0; i < hash.Count; i++) { sbResult.AppendFormat("{0:x2}", hash[i]); } return sbResult.ToString(); } catch { return null; } }
Podpisa ni več, ker so me poskušali asimilirati.
- zaklenil: BluPhenix ()
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | [c#] shrani text, tabele, slikeOddelek: Programiranje | 1525 (1131) | klemen93 |
» | [java] Kako v memoriji pretvoriti String objekt v File objekt ? - neka metoda ga zahtOddelek: Programiranje | 2272 (2272) | infiniteLoop |
» | [asp.net] simpl image editorOddelek: Programiranje | 1560 (1365) | darkolord |
» | branje byte[] iz MS access-ove bazeOddelek: Programiranje | 1944 (1854) | BHawk |
» | Odpiranje dat.exe v VBOddelek: Programiranje | 3007 (2800) | webblod |