1 | sbool md5OfFile_verbose; |
2 | |
3 | static S md5OfFile(S path) { |
4 | ret md5OfFile(newFile(path)); |
5 | } |
6 | |
7 | static S md5OfFile(File f) ctex { |
8 | if (!f.exists()) ret "-"; |
9 | |
10 | if (md5OfFile_verbose) |
11 | print("Getting MD5 of " + f); |
12 | |
13 | MessageDigest md5 = MessageDigest.getInstance("MD5"); |
14 | temp FileInputStream in = new FileInputStream(f); |
15 | |
16 | byte buf[] = new byte[65536]; |
17 | int l; |
18 | while (true) { |
19 | l = in.read(buf); |
20 | if (l <= 0) break; |
21 | md5.update(buf, 0, l); |
22 | } |
23 | |
24 | ret bytesToHex(md5.digest()); |
25 | } |
Began life as a copy of #1000998
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney
No comments. add comment
Snippet ID: | #1016251 |
Snippet name: | md5OfFile |
Eternal ID of this version: | #1016251/4 |
Text MD5: | 37fa3d5071937a26d94cc37946b2bf8c |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-12-28 14:15:06 |
Source code size: | 520 bytes / 25 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 419 / 485 |
Version history: | 3 change(s) |
Referenced in: | [show references] |