Mercurial > ec-dotfiles
annotate bin/ed2k @ 734:02d746e77fab
[vimrc] Remove forcing 256 colors for screen term
It was for tmux but it now sets tmux-256color by default.
| author | nanaya <me@nanaya.net> |
|---|---|
| date | Thu, 09 Jan 2025 00:50:00 +0900 |
| parents | bcdf320dabf4 |
| children | 8d3ad5ae1ce4 |
| rev | line source |
|---|---|
| 719 | 1 #!/usr/bin/env php |
| 2 <?php | |
| 3 | |
| 4 function ed2k_hash(string $path): string | |
| 5 { | |
| 6 // ed2k hash is an md4 hash of concatenated binary md4 hashes of 9500 KiB file chunks. | |
| 7 static $bs = 9500 * 1024; | |
| 8 $hash = ''; | |
| 9 $fp = fopen($path, 'rb'); | |
|
4
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
10 |
| 719 | 11 while (!feof($fp)) { |
| 12 $hash .= hash('md4', fread($fp, $bs), true); | |
| 13 } | |
| 14 fclose($fp); | |
| 15 | |
| 16 return hash('md4', $hash); | |
| 17 } | |
|
4
94ee419ad047
Added bin-ec - a collection of scripts.
Edho Prima Arief <me@myconan.net>
parents:
diff
changeset
|
18 |
| 719 | 19 for ($i = 1; $i < $argc; $i++) { |
| 20 $path = $argv[$i]; | |
| 21 $hash = ed2k_hash($path); | |
| 22 $filename = basename($path); | |
| 23 $filesize = filesize($path); | |
| 24 | |
| 25 echo "ed2k://|file|{$filename}|{$filesize}|{$hash}|"; | |
| 26 echo PHP_EOL; | |
| 27 } |
