From: Randima Hettiarachchi on
Walter Roberson <roberson(a)hushmail.com> wrote in message <hsuls8$329$1(a)canopus.cc.umanitoba.ca>...
> Randima Hettiarachchi wrote:
> > Walter Roberson <roberson(a)hushmail.com> wrote in message
> > <pgyIn.16948$Ak3.5716(a)newsfe16.iad>...
> >> Randima Hettiarachchi wrote:
> >> > Walter Roberson <roberson(a)hushmail.com> wrote in message >
> >> <HexIn.11217$wV.2695(a)newsfe11.iad>...
> >> >> Randima Hettiarachchi wrote:
> >> >>
> >> >> > Thanks a lot. But my original challenge was to calculate the hash
> >> >> value > of a given image as a bit sequence by using a standard >>
> >> encryption > algorithm like MD5, MD4 or SHA. It is much appreciated if
> >> >> you can > provide some clues on that.
> >> >>
> >> >> You mean like the Matlab File Exchange contribution
> >> >> Compute hash using MD2, MD5, SHA-1, SHA-256, SHA-384, or SHA-512
> >> >>
> >> >> by Michael Kleder
> >> >>
> >> >> ?
> >> > > Exactly. The only problem I experienced with the above mentioned
> >> files > shared by Michael Kleder is that those were not implemented to
> >> accept > images as input to the function.
> >>
> >> But that's okay, because I showed you how to convert the image into a
> >> bit stream.
> >
> > Sir, do you recommend to feed the image pixel by pixel to the encryption
> > algorithm or just to use the matrix created by using dec2bin() as the
> > image hash?
>
> If you examine Chris Rodgers' comment
> http://www.mathworks.com/matlabcentral/fileexchange/8944-compute-hash-using-md2-md5-sha-1-sha-256-sha-384-or-sha-512
>
> then I think it probable that his update would also be suitable for handling
> complete images, with no need to send the image bit-by-bit.
>
> The matrix created by dec2bin() is *not* suitable as the hash itself.

Many thanks sir. I was able to rectify the problem I was facing with your kind help...
From: fiza khalid on
"Randima Hettiarachchi" <randishi(a)yahoo.com> wrote in message <hug9ot$3tb$1(a)fred.mathworks.com>...
> Walter Roberson <roberson(a)hushmail.com> wrote in message <hsuls8$329$1(a)canopus.cc.umanitoba.ca>...
> > Randima Hettiarachchi wrote:
> > > Walter Roberson <roberson(a)hushmail.com> wrote in message
> > > <pgyIn.16948$Ak3.5716(a)newsfe16.iad>...
> > >> Randima Hettiarachchi wrote:
> > >> > Walter Roberson <roberson(a)hushmail.com> wrote in message >
> > >> <HexIn.11217$wV.2695(a)newsfe11.iad>...
> > >> >> Randima Hettiarachchi wrote:
> > >> >>
> > >> >> > Thanks a lot. But my original challenge was to calculate the hash
> > >> >> value > of a given image as a bit sequence by using a standard >>
> > >> encryption > algorithm like MD5, MD4 or SHA. It is much appreciated if
> > >> >> you can > provide some clues on that.
> > >> >>
> > >> >> You mean like the Matlab File Exchange contribution
> > >> >> Compute hash using MD2, MD5, SHA-1, SHA-256, SHA-384, or SHA-512
> > >> >>
> > >> >> by Michael Kleder
> > >> >>
> > >> >> ?
> > >> > > Exactly. The only problem I experienced with the above mentioned
> > >> files > shared by Michael Kleder is that those were not implemented to
> > >> accept > images as input to the function.
> > >>
> > >> But that's okay, because I showed you how to convert the image into a
> > >> bit stream.
> > >
> > > Sir, do you recommend to feed the image pixel by pixel to the encryption
> > > algorithm or just to use the matrix created by using dec2bin() as the
> > > image hash?
> >
> > If you examine Chris Rodgers' comment
> > http://www.mathworks.com/matlabcentral/fileexchange/8944-compute-hash-using-md2-md5-sha-1-sha-256-sha-384-or-sha-512
> >
> > then I think it probable that his update would also be suitable for handling
> > complete images, with no need to send the image bit-by-bit.
> >
> > The matrix created by dec2bin() is *not* suitable as the hash itself.
>
> Many thanks sir. I was able to rectify the problem I was facing with your kind help...
>> hi
i have the same problem which i am trying to implement plz help me if u have done that.
From: Randima Hettiarachchi on
> >> hi
> i have the same problem which i am trying to implement plz help me if u have done that.

Hi Fiza,

Visit this link and directly go to Chris Rodgers' comment
> http://www.mathworks.com/matlabcentral/fileexchange/8944-compute-hash-using-md2-md5-sha-1-sha-256-sha-384-or-sha-512.

the comment says;

"To cope with complex input, replace with this code from line 46:

else % convert everything else into uint8 format without loss of data
if ~isreal(inp)
inp=reshape([real(inp(:)).'; imag(inp(:)).'],[],1);
end
inp=typecast(inp,'uint8');
end "

So you only have to replace the else condition, which starts from line 46 in the current code with the above else part.

Let me know if you need more help.

Randima
From: Jan Simon on
Dear Randima!

> I'm doing a research, which requires the hash value of an image to be calculated as a sequence of 0's and 1's (eg:- 11100101). Any standard algorithm MD5, MD4 or SHA would be fine in calculating image. If some one can help me or give some hints I would be thankful...

Perhaps I've overseen it - did you define, what "image" means in your case? Do you mean a [X, Y, 3] double RGB array, an image file or a the reply of IMREAD (X and MAP)?
In all three cases a few lines are enough to convert the data to a UINT8 vector and call Kleder's function to calculate the hash as [1 x 16] UINT8 vector. This vector can be casted to a DOUBLE and DEC2BIN creates your bitsequence.

Jan
From: fiza khalid on
"Randima Hettiarachchi" <randishi(a)yahoo.com> wrote in message <hv1jfn$hk2$1(a)fred.mathworks.com>...
> > >> hi
> > i have the same problem which i am trying to implement plz help me if u have done that.
>
> Hi Fiza,
>
> Visit this link and directly go to Chris Rodgers' comment
> > http://www.mathworks.com/matlabcentral/fileexchange/8944-compute-hash-using-md2-md5-sha-1-sha-256-sha-384-or-sha-512.
>
> the comment says;
>
> "To cope with complex input, replace with this code from line 46:
>
> else % convert everything else into uint8 format without loss of data
> if ~isreal(inp)
> inp=reshape([real(inp(:)).'; imag(inp(:)).'],[],1);
> end
> inp=typecast(inp,'uint8');
> end "
>
> So you only have to replace the else condition, which starts from line 46 in the current code with the above else part.
>
> Let me know if you need more help.
>
> Randima

>>thankyou 4 your support but please tell me the code which u refer to me how i can run that as i got error when i tried to run that.that code is using java files.i need to know which java files i need to install to run that code in Matlab.please do reply me and help me.