Sample code for 30+ languages & platforms
Java

Compute Glacier SHA256 Linear Hash of a File

See more Amazon Glacier Examples

Computes the Amazon Glacier SHA256 linear hash for a file.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.Crypt2;

public class ChilkatExample {

    public static void main(String[] args) {
        // This example requires the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        Crypt2 crypt = new Crypt2();

        // The "linear hash" is simply the SHA256 hash of the file bytes.
        crypt.setHashAlgorithm("sha256");

        // Return the hash in lowercase hexidecimal format.
        crypt.setEncodingMode("hexlower");

        String linearHashHex = crypt.hashFileENC("qa_data/jpg/penguins.jpg");
        System.out.println("SHA256 linear hash = " + linearHashHex);
    }
}