Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

16
LINES

< > BotCompany Repo | #1035806 // md5OfFileAsByteArray

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (103L/1K).

1  
static byte[] md5OfFileAsByteArray(File f) ctex {
2  
  if (!isFile(f)) null;
3  
  
4  
  var md5 = MessageDigest.getInstance("MD5");
5  
  temp FileInputStream in = new FileInputStream(f);
6  
7  
  byte buf[] = new byte[65536];
8  
  int l;
9  
  while (true) {
10  
    l = in.read(buf);
11  
    if (l <= 0) break;
12  
    md5.update(buf, 0, l);
13  
  }
14  
  
15  
  ret md5.digest();
16  
}

Author comment

Began life as a copy of #1016251

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1035806
Snippet name: md5OfFileAsByteArray
Eternal ID of this version: #1035806/1
Text MD5: b34da98d46c5448a1b73ce18716c8e63
Transpilation MD5: 99f27f247963a3235f3101027ab4e34c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-07-29 21:17:40
Source code size: 349 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 52 / 75
Referenced in: [show references]