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

27
LINES

< > BotCompany Repo | #1035803 // MD5 - MD5 checksum represented as an object

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

Libraryless. Click here for Pure Java version (9488L/52K).

srecord MD5(long a, long b) {
  *(byte[] data) {
    loadDigest(md5AsByteArray(data));
  }
  
  *(File f) {
    loadDigest(md5OfFileAsByteArray(f));
  }
  
  // md5 is the digest, not the data being checksummed
  static MD5 ofDigest(byte[] digest) {
    ret new MD5().loadDigest(digest);
  }
  
  selfType loadDigest(byte[] digest) {
    assertEquals("MD5 digest", 16, l(digest));
    a = longFromBytes_bigEndian(digest, 0);
    b = longFromBytes_bigEndian(digest, 8);
    this;
  }
  
  *(S md5) {
    this(parseHexBytes(md5));
  }
  
  toString { ret "MD5=" + longToHex(a) + longToHex(b); }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1035803
Snippet name: MD5 - MD5 checksum represented as an object
Eternal ID of this version: #1035803/6
Text MD5: 658179141a3e2aeee8e13e0da484147c
Transpilation MD5: ed4377c92bb1c98402c58de1cb8262a6
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:45:36
Source code size: 620 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 144 / 243
Version history: 5 change(s)
Referenced in: #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167)