Skip to content
Snippets Groups Projects
Commit 7ace852c authored by rswindell's avatar rswindell
Browse files

Acts like the Unix/Linux md5sum command to calculate and display MD5 digests

(in hex) of files or strings.
parent baf3a745
No related branches found
No related tags found
No related merge requests found
/* md5sum.js */
/* Calculate and displays MD5 digest (in hex) of specified file or string */
/* $Id$ */
var filename;
var binary=true;
for(i=0;i<argc;i++) {
if(argv[i].substring(0,2)=="-s") {
print(md5_calc(argv[i].substr(2),true));
exit();
}
else if(argv[i]=="-b" || argv[i]=="--binary")
binary=true;
else if(argv[i]=="-t" || argv[i]=="--text")
binary=false;
else
filename = argv[i];
}
if(!filename) {
alert("no filename specified");
exit();
}
file = new File(filename);
print("opening ", filename);
if(!file.open(binary ? "rb" : "r")) {
alert("!Error " + file.error + " opening " + filename);
exit();
}
print(file.md5_hex, " ", binary ? "*":" ", filename);
file.close();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment