Suggest me the best image encryption algorithm
5 views (last 30 days)
Show older comments
Hi I am Sai and I am looking for an image encryption algorithm that is
Priority 1 : Light (Less time consuming) and
Priority 2 : Efficient (Strong)
Please help me with your suggestions.
Thanks in advance!
0 Comments
Answers (1)
Jan
on 24 Aug 2021
Edited: Jan
on 24 Aug 2021
A short answer: AES-CBC.
An implementation:
key = uint8('myPassword');
data = randi([0, 255], 640, 480, 3, 'uint8');
% Get a 16 byte hash from the password:
Hashing = java.security.MessageDigest.getInstance('MD5');
Hashing.update(key);
Hash = typecast(Hashing.digest, 'uint8');
% Set up algorithm:
Engine = javax.crypto.spec.SecretKeySpec(Hash, 'AES');
Cipher = javax.crypto.Cipher.getInstance('AES/CBC/PKCS5Padding');
% Encrypt:
Cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, Engine);
encrypted = typecast(Cipher.doFinal(data(:)), 'uint8');
% Decrypt:
Cipher.init(javax.crypto.Cipher.DECRYPT_MODE, Engine);
decrypted = typecast(Cipher.doFinal(encrypted(:)), 'uint8');
% Compare the results - of course the shape of the array has not been
% considered yet:
isequal(decrypted(:), data(:))
0 Comments
See Also
Categories
Find more on Encryption / Cryptography in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!