VIDEO ENCRYPTION
조회 수: 7 (최근 30일)
이전 댓글 표시
Presently I need any code for video encryption in matlab.any method!!video format .mpg
댓글 수: 0
답변 (2개)
Walter Roberson
2012년 4월 10일
Caesar Cypher the frames.
댓글 수: 2
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
2021년 4월 29일
편집: 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
댓글 수: 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!