(Java) Compute Glacier SHA256 Linear Hash of a File
Computes the Amazon Glacier SHA256 linear hash for a file.
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkCrypt2 crypt = new CkCrypt2();
// The "linear hash" is simply the SHA256 hash of the file bytes.
crypt.put_HashAlgorithm("sha256");
// Return the hash in lowercase hexidecimal format.
crypt.put_EncodingMode("hexlower");
String linearHashHex = crypt.hashFileENC("qa_data/jpg/penguins.jpg");
System.out.println("SHA256 linear hash = " + linearHashHex);
}
}
|