1、MATLAB实现
计算图像哈希值SHA-512,在文献[1]提到的算法如下:
% Example Code: Create an MD5 crypto-hash of an arbitrary string, "str"
% Main class of interest: System.Security.Cryptography.HashAlgorithm
% Example String to hash with MD5
% str = 'hello there big world';
% str= ' i love china';
myx=imread('lena.jpg');
% Image_As_A_vector = reshape(typecast(myx, 'uint8'), 1, []));
array_in=char(strjoin(string(reshape(myx,1,[]))));
str=array_in;
% Create any specified cryptographic hasher.
% Supported string args include 'MD5', 'SHA1', 'SHA256', 'SHA384', 'SHA512'.
% That's what I could figure out by random guessing... 'SHA3'