VIDEO ENCRYPTION

7 次查看(过去 30 天)
LOKESH
LOKESH 2012-4-10
Presently I need any code for video encryption in matlab.any method!!video format .mpg

回答(2 个)

Walter Roberson
Walter Roberson 2012-4-10
Caesar Cypher the frames.
  2 个评论
LOKESH
LOKESH 2012-4-13
I have avi or mpg video. I am extracting the frames. Do I need to save these frames as images & then perform encryption as images.
Also how could I convert the images back to video...
Thanks!!
Walter Roberson
Walter Roberson 2012-4-13
When you extract a frame, you will get an array of data as the result. Encrypt that array. Use VideoWriter() to write the frame to a new video.

请先登录,再进行评论。


dharmavarapu yugandhar kumar
编辑:Walter Roberson 2023-3-19
classdef AES < handle
%UNTITLED Summary of this class goes here
% Detailed explanation goes here
properties (Access = private)
secretKey
cipher
end
methods
function obj = AES(secret, algorithm)
%AES Construct an instance of this class
% algorithm options are https://docs.oracle.com/javase/9/docs/specs/security/standard-names.html#messagedigest-algorithms
import java.security.MessageDigest;
import java.lang.String;
import java.util.Arrays;
import javax.crypto.Cipher;
key = String(secret).getBytes("UTF-8");
sha = MessageDigest.getInstance(algorithm);
key = sha.digest(key);
key = Arrays.copyOf(key, 16);
obj.secretKey = javaObject('javax.crypto.spec.SecretKeySpec',key, "AES");
obj.cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
end
function encrypted = encrypt(obj, strToEncrypt)
%ENCRYPT Summary of this method goes here
% Detailed explanation goes here
import java.util.Base64;
import java.lang.String;
import javax.crypto.Cipher;
obj.cipher.init(Cipher.ENCRYPT_MODE, obj.secretKey);
encrypted = string(Base64.getEncoder().encodeToString(obj.cipher.doFinal(String(strToEncrypt).getBytes("UTF-8"))));
end
function encrypted = encryptStructuredData(obj, structuredData)
encrypted = obj.encrypt(jsonencode(structuredData));
end
function decrypted = decryptStructuredData(obj, encryptedStructuredData)
decrypted = jsondecode(obj.decrypt(encryptedStructuredData));
end
function decrypted = decrypt(obj, strToDecrypt)
%DECRYPT Summary of this method goes here
% Detailed explanation goes here
import javax.crypto.Cipher;
import java.lang.String;
import java.util.Base64;
obj.cipher.init(Cipher.DECRYPT_MODE, obj.secretKey);
decrypted = string(String(obj.cipher.doFinal(Base64.getDecoder().decode(strToDecrypt))));
end
end
end

类别

Help CenterFile Exchange 中查找有关 Encryption / Cryptography 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by