Suggest me the best image encryption algorithm
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Jan
2021-8-24
编辑:Jan
2021-8-24
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Encryption / Cryptography 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!