Sample code for 30+ languages & platforms
PureBasic

Compute Glacier SHA256 Linear Hash of a File

See more Amazon Glacier Examples

Computes the Amazon Glacier SHA256 linear hash for a file.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkCrypt2.pb"

Procedure ChilkatExample()

    ; This example requires the Chilkat API to have been previously unlocked.
    ; See Global Unlock Sample for sample code.

    crypt.i = CkCrypt2::ckCreate()
    If crypt.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ; The "linear hash" is simply the SHA256 hash of the file bytes.
    CkCrypt2::setCkHashAlgorithm(crypt, "sha256")

    ; Return the hash in lowercase hexidecimal format.
    CkCrypt2::setCkEncodingMode(crypt, "hexlower")

    linearHashHex.s = CkCrypt2::ckHashFileENC(crypt,"qa_data/jpg/penguins.jpg")
    Debug "SHA256 linear hash = " + linearHashHex


    CkCrypt2::ckDispose(crypt)


    ProcedureReturn
EndProcedure