Oregami
Repositories/oxedyne/fe2o3

oxedyne/fe2o3/fe2o3_text/tests/detect_corpus/java/package_decl.txt

995 bytes, 1 run

created by r1870400018:11994, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1package com.oxedyne.util;
2
3import java.security.MessageDigest;
4import java.security.NoSuchAlgorithmException;
5import java.nio.charset.StandardCharsets;
6
7public final class Hashing {
8
9 private Hashing() {}
10
11 public static byte[] sha256(byte[] input) {
12 try {
13 MessageDigest digest = MessageDigest.getInstance("SHA-256");
14 return digest.digest(input);
15 } catch (NoSuchAlgorithmException e) {
16 throw new RuntimeException("SHA-256 not available", e);
17 }
18 }
19
20 public static String sha256Hex(String input) {
21 byte[] hash = sha256(input.getBytes(StandardCharsets.UTF_8));
22 StringBuilder sb = new StringBuilder(hash.length * 2);
23 for (byte b : hash) {
24 sb.append(String.format("%02x", b & 0xff));
25 }
26 return sb.toString();
27 }
28
29 public static void main(String[] args) {
30 for (String arg : args) {
31 System.out.printf("%s %s%n", sha256Hex(arg), arg);
32 }
33 }
34}