From 40efdd34d40100dc045c8e8ed9b9030a3cc2343c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 5 Feb 2013 01:19:54 +0100 Subject: different commands for different output sizes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- java/sha3_224sum.java | 42 ++++++++++++++++++++++++++++++++++++++++++ java/sha3_256sum.java | 42 ++++++++++++++++++++++++++++++++++++++++++ java/sha3_384sum.java | 42 ++++++++++++++++++++++++++++++++++++++++++ java/sha3_512sum.java | 42 ++++++++++++++++++++++++++++++++++++++++++ java/sha3sum.java | 25 +++++++++++++++++++------ 5 files changed, 187 insertions(+), 6 deletions(-) create mode 100644 java/sha3_224sum.java create mode 100644 java/sha3_256sum.java create mode 100644 java/sha3_384sum.java create mode 100644 java/sha3_512sum.java diff --git a/java/sha3_224sum.java b/java/sha3_224sum.java new file mode 100644 index 0000000..fbed9a5 --- /dev/null +++ b/java/sha3_224sum.java @@ -0,0 +1,42 @@ +/** + * sha3sum – SHA-3 (Keccak) checksum calculator + * + * Copyright © 2013 Mattias Andrée (maandree@member.fsf.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import java.io.*; +import java.util.*; + + +/** + * SHA-3/Keccak checksum calculator with 224 bit output + * + * @author Mattias Andrée maandree@member.fsf.org + */ +public class sha3_224sum +{ + /** + * This is the main entry point of the program + * + * @param args Command line arguments + * @throws IOException On I/O error (such as broken pipes) + */ + public static void main(String[] args) throws IOException + { + sha3sum.run("sha3-224sum", args); + } +} + diff --git a/java/sha3_256sum.java b/java/sha3_256sum.java new file mode 100644 index 0000000..4f06f1d --- /dev/null +++ b/java/sha3_256sum.java @@ -0,0 +1,42 @@ +/** + * sha3sum – SHA-3 (Keccak) checksum calculator + * + * Copyright © 2013 Mattias Andrée (maandree@member.fsf.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import java.io.*; +import java.util.*; + + +/** + * SHA-3/Keccak checksum calculator with 256 bit output + * + * @author Mattias Andrée maandree@member.fsf.org + */ +public class sha3_256sum +{ + /** + * This is the main entry point of the program + * + * @param args Command line arguments + * @throws IOException On I/O error (such as broken pipes) + */ + public static void main(String[] args) throws IOException + { + sha3sum.run("sha3-256sum", args); + } +} + diff --git a/java/sha3_384sum.java b/java/sha3_384sum.java new file mode 100644 index 0000000..8ca1552 --- /dev/null +++ b/java/sha3_384sum.java @@ -0,0 +1,42 @@ +/** + * sha3sum – SHA-3 (Keccak) checksum calculator + * + * Copyright © 2013 Mattias Andrée (maandree@member.fsf.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import java.io.*; +import java.util.*; + + +/** + * SHA-3/Keccak checksum calculator with 384 bit output + * + * @author Mattias Andrée maandree@member.fsf.org + */ +public class sha3_384sum +{ + /** + * This is the main entry point of the program + * + * @param args Command line arguments + * @throws IOException On I/O error (such as broken pipes) + */ + public static void main(String[] args) throws IOException + { + sha3sum.run("sha3-384sum", args); + } +} + diff --git a/java/sha3_512sum.java b/java/sha3_512sum.java new file mode 100644 index 0000000..59e294a --- /dev/null +++ b/java/sha3_512sum.java @@ -0,0 +1,42 @@ +/** + * sha3sum – SHA-3 (Keccak) checksum calculator + * + * Copyright © 2013 Mattias Andrée (maandree@member.fsf.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import java.io.*; +import java.util.*; + + +/** + * SHA-3/Keccak checksum calculator with 512 bit output + * + * @author Mattias Andrée maandree@member.fsf.org + */ +public class sha3_512sum +{ + /** + * This is the main entry point of the program + * + * @param args Command line arguments + * @throws IOException On I/O error (such as broken pipes) + */ + public static void main(String[] args) throws IOException + { + sha3sum.run("sha3-512sum", args); + } +} + diff --git a/java/sha3sum.java b/java/sha3sum.java index 6a122ff..ec00958 100644 --- a/java/sha3sum.java +++ b/java/sha3sum.java @@ -22,7 +22,7 @@ import java.util.*; /** - * SHA-3/Keccak chechsum calculator + * SHA-3/Keccak checksum calculator * * @author Mattias Andrée maandree@member.fsf.org */ @@ -31,12 +31,24 @@ public class sha3sum /** * This is the main entry point of the program * + * @param args Command line arguments + * @throws IOException On I/O error (such as broken pipes) + */ + public static void main(String[] args) throws IOException + { + run("sha3sum", args); + } + + + /** + * Run the program + * + * @param cmd The command * @param argv Command line arguments * @throws IOException On I/O error (such as broken pipes) */ - public static void main(String[] argv) throws IOException + public static void run(String cmd, String[] argv) throws IOException { - String cmd, _cmd = cmd = ""; //FIXME /proc/self/cmdline split ^@ [0] if (cmd.indexOf('/') >= 0) cmd = cmd.substring(cmd.lastIndexOf('/') + 1); if (cmd.endsWith(".jar")) @@ -138,7 +150,7 @@ public class sha3sum i = Integer.parseInt(linger[1]); else { - System.err.println(_cmd + ": unrecognised option: " + linger[0]); + System.err.println(cmd + ": unrecognised option: " + linger[0]); System.exit(1); } } @@ -183,7 +195,7 @@ public class sha3sum files[fptr++] = null; if (i < 1) { - System.err.println(_cmd + ": sorry, I will only do at least one iteration!\n"); + System.err.println(cmd + ": sorry, I will only do at least one iteration!\n"); System.exit(3); } @@ -237,7 +249,7 @@ public class sha3sum } } catch (final IOException err) - { System.err.println(_cmd + ": Cannot read file: " + filename + ": " + err); + { System.err.println(cmd + ": Cannot read file: " + filename + ": " + err); fail = true; } finally @@ -253,5 +265,6 @@ public class sha3sum if (fail) System.exit(5); } + } -- cgit v1.2.3-70-g09d2