Page 1 of 1

GetImageHash

Posted: Wed Oct 23, 2024 10:34 am
by Horizon
Hi,

I ask AI to create Hash for an image.

Code: Select all | Expand

FUNCTION GetImageHash(cFileName)
    LOCAL nHandle, cBuffer, nHash, nByte, i

    nHandle := FOPEN(cFileName, 0)   // Dosyayı okumak için aç
    IF nHandle < 0
        ? "Dosya açılamadı"
        RETURN NIL
    ENDIF

    nHash := 0
    DO WHILE FREAD(nHandle, @cBuffer, 1) > 0
        nByte := ASC(cBuffer)
        nHash := BITOR(BITLSHIFT(nHash, 5) - nHash, nByte)
    ENDDO

    FCLOSE(nHandle)

    RETURN nHash
Change BITOR to hb_BITOR, BITLSHIFT to hb_BITSHIFT.

I could not get any result. Can you help me?

Thanks

Re: GetImageHash

Posted: Wed Oct 23, 2024 2:47 pm
by Antonio Linares
Dear Hakan,

Please try this:

MsgInfo( nFileCRC( "yourimage.png" ) ) // any image extension

Re: GetImageHash

Posted: Thu Oct 24, 2024 7:10 am
by Horizon
Antonio Linares wrote:Dear Hakan,

Please try this:

MsgInfo( nFileCRC( "yourimage.png" ) ) // any image extension
I will try.

Thanks.