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).

1  
srecord MD5(long a, long b) {
2  
  *(byte[] data) {
3  
    loadDigest(md5AsByteArray(data));
4  
  }
5  
  
6  
  *(File f) {
7  
    loadDigest(md5OfFileAsByteArray(f));
8  
  }
9  
  
10  
  // md5 is the digest, not the data being checksummed
11  
  static MD5 ofDigest(byte[] digest) {
12  
    ret new MD5().loadDigest(digest);
13  
  }
14  
  
15  
  selfType loadDigest(byte[] digest) {
16  
    assertEquals("MD5 digest", 16, l(digest));
17  
    a = longFromBytes_bigEndian(digest, 0);
18  
    b = longFromBytes_bigEndian(digest, 8);
19  
    this;
20  
  }
21  
  
22  
  *(S md5) {
23  
    this(parseHexBytes(md5));
24  
  }
25  
  
26  
  toString { ret "MD5=" + longToHex(a) + longToHex(b); }
27  
}

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: 143 / 243
Version history: 5 change(s)
Referenced in: [show references]