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

16
LINES

< > BotCompany Repo | #1033926 // zipFileToJSONFingerprint - list each file name with crc, size and date (giving a reasonable certainty that 2 files are identical)

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

Libraryless. Click here for Pure Java version (4727L/27K).

// Note: Zip CRCs are spoofable. But we use this for program updates,
// so no malicious parties involved

static L<Map> zipFileToJSONFingerprint(File zip) {
  temp zipFile = zipFile(zip);
  ret zipFileToJSONFingerprint(zipFile);
}

static L<Map> zipFileToJSONFingerprint(ZipFile zip) {
  ret map(listZipEntries(zip), e ->
    litorderedmap(name := e.getName(),
      size := e.getSize(),
      crc := intToHex((int) e.getCrc()),
      date := e.getTime()/1000,
    ));
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033926
Snippet name: zipFileToJSONFingerprint - list each file name with crc, size and date (giving a reasonable certainty that 2 files are identical)
Eternal ID of this version: #1033926/7
Text MD5: a12108d72f00b99ef426c781da954f2c
Transpilation MD5: 0c1db4a28eaf4f2b7607ca9abf3f4c43
Author: stefan
Category: javax / io
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-12 17:59:17
Source code size: 486 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 137 / 221
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1034019 - zipFileToJSONFingerprint_dateOnly - list each file name with date