Azzera filtri
Azzera filtri

Suggest me the best image encryption algorithm

10 visualizzazioni (ultimi 30 giorni)
Gottumukkala Sai
Gottumukkala Sai il 24 Ago 2021
Modificato: Jan il 24 Ago 2021
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!

Risposte (1)

Jan
Jan il 24 Ago 2021
Modificato: Jan il 24 Ago 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(:))
ans = logical
1

Categorie

Scopri di più su Encryption / Cryptography in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by