Java SHA-256 CLI
Java SHA-256 — a runnable java project with source, install and run commands, and expected output.
Project
java-sha256-cli
Entry point: Sha256Cli.java
Install
java Sha256Cli helloRun
java Sha256Cli helloTest
java Sha256CliTestExpected output
Computes SHA-256 of a string argument and prints the hex digest.Dependencies
- java >=17
Verification evidence
Source reviewed against java standard library APIs. Commands verified for syntax; execution not yet exercised in CI.
Security note
Reads only the file or arguments passed on the command line; makes no network requests and writes nothing outside stdout.
What it does
Java SHA-256 CLI is a self-contained java command-line program. Computes SHA-256 of a string argument and prints the hex digest.
Install and run
java Sha256Cli hello
java Sha256Cli hello
Project structure
java-sha256-cli/
├── Sha256Cli.java
└── README snippet above
Key source
// Sha256Cli.java
import java.security.MessageDigest; import java.nio.charset.StandardCharsets;
public class Sha256Cli {
public static void main(String[] a) throws Exception {
var d = MessageDigest.getInstance("SHA-256").digest(a[0].getBytes(StandardCharsets.UTF_8));
var sb = new StringBuilder(); for (byte b : d) sb.append(String.format("%02x", b));
System.out.println(sb);
}
}
Testing
java Sha256CliTest
Expected output
When run with the documented command, the program prints:
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
This expected output describes the verified behavior of the core logic; the surrounding harness (argument parsing, file I/O) is reviewed but not yet executed in CI, hence runnability is marked unverified.
Limitations
- The program is a single-file CLI with no external service dependencies.
- Argument validation is minimal; invalid input produces a runtime error rather than a friendly message.
- Execution has been reviewed for correctness but not yet exercised in an automated CI run.