image encryption using AES algorithm
MATLAB: How can generate the code for aes algorithm
aesencryptionimage
Related Solutions
While posting code here or in the FileExchange is forbidden, because the data are hosted inside the US, you find several implementations when you ask your favorite internet search engine. So, rula, please try this at first before asking the forum to post the corresponding links for you. Because I've talked about AES repeatedly, my name could be helpful in a search also. Thanks.
Your call of DataHash creates the hash considering the class of the obejct. You want to get the hash for the values only.
challenge = 'c100b894-1729-464d-ace1-52dbce11db42';Opt.Method = 'SHA-256';Opt.Input = 'ascii'; % Use the contents only and only 8 bits
hash_digest = DataHash(challenge, Opt)% Compare with:
DataHash(challenge, struct('Method','SHA-256'))% Note that this considers the class and dimensions of the input also:
DataHash(challenge.', struct('Method','SHA-256'))% ^^ other result for transposed input!!!
By the way, DataHash is an overkill here. Leaner:
Engine = java.security.MessageDigest.getInstance('SHA-256');Engine.update(uint8(challenge(:)));Hash = typecast(Engine.digest, 'uint8')
And for HMAC:
BlockSize = 128; % 64 for: MD5, SHA-1, SHA-256
KeySize = numel(Key);Key = uint8(Key); % Hash it if it is longer than BlockSize
ipad(1:BlockSize) = uint8(54); % 0x36
ipad(1:KeySize) = bitxor(uint8(54), Key);opad(1:BlockSize) = uint8(92); % 0x5c
opad(1:KeySize) = bitxor(uint8(92), Key);Engine2 = java.security.MessageDigest.getInstance('SHA-512');Engine2.update(ipad);Engine2.update(uint8(Msg));iHash = typecast(Engine2.digest, 'uint8');Engine2.update(opad);Engine2.update(iHash);HMAC = typecast(Engine2.digest, 'uint8');
Best Answer