video encryption mini project content

Upload: suganya-selvaraj

Post on 02-Apr-2018

227 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 Video encryption Mini project Content

    1/43

    1. INTRODUCTION

    1.1 INTRODUCTION

    The rapid growth of Internet and digitized content has made video distribution easy. Hence

    the need for video data protection is on the rise. Therefore, multimedia encryption is needed for the

    complete confidentiality. Classic encryption algorithms like DES (Data Encryption Standard), AES

    (Advanced Encryption Standard) etc., are computationally infeasible for video data. They take

    large amount of time for encrypting huge video data. To decrease the encryption time, some

    encryption algorithms used simple scrambling mechanisms. Evidently they are insecure. Moreover,

    these algorithms typically neglected the data format of the videos, thus burdening compression

    phase of codec.

    Owing to the large size and real-time applications of video, two types of encryption

    algorithms are generally in vogue. One method is selective encryption. In this method, only parts of

    the video content are encrypted, thereby reducing the computational requirement (time). This

    method is not suitable because the full content of the video is not critical. Another method is the

    light-weight encryption which trades off security for computational time.

    1

  • 7/27/2019 Video encryption Mini project Content

    2/43

    1.2 OBJECTIVE

    The objective is to propose a secure and computationally feasible video encryption

    algorithm based on the method of Secret Sharing. In an MPEG video, the strength of the DC is

    distributed among the AC values based on Shamirs Secret Sharing (SSS) scheme. The proposed

    algorithm guarantees security, speed and error tolerance with a small increase in video size. There

    is a need for a new secure video encryption algorithm perhaps designed by combining these two

    classes, which retains their respective advantages, while minimizing the disadvantages. Apparently

    a naive combination is worse compared to each one of them individually if one wants to reduce

    the time, then one may opt for selective light-weight encryption, which degrades the security. If

    one attempts to improve security by the Shannons principle of selective permute-then-encrypt, it

    increases the computational time.

    2

  • 7/27/2019 Video encryption Mini project Content

    3/43

    2. SYSTEM ANALYSIS

    2.1 EXISTING SYSTEM

    In the existing system, the selective encryption algorithm typically uses heavy-weight

    encryption algorithms (eg. DES, AES etc.). Consequently, time taken for the encryption using them

    is high making them unsuitable for real-time applications. On the other hand, most of the known

    light-weight algorithms are susceptible to known plaintext-only and ciphertext-only attacks.

    Therefore, there is a need for a new secure video encryption algorithm perhaps designed by

    combining these two classes, which retains their respective advantages, while minimizing the

    disadvantages. Apparently a naive combination is worse compared to each one of them

    individually if one wants to reduce the time, then one may opt for selective light-weight

    encryption, which degrades the security. If one attempts to improve security by the Shannons

    principle of selective permute-then-encrypt, it increases the computational time.

    2.1.1 LIMITATIONS

    The existing video encryption techniques are not feasible.

    The security is very low.

    Cannot overcome the secret sharing attacks

    3

  • 7/27/2019 Video encryption Mini project Content

    4/43

    2.2 PROPOSED SYSTEM

    In the proposed system, we propose a selective cum light-weight encryption algorithm

    which is fast enough for real-time applications, yet possessing practically acceptable levels of

    security. Discrete Cosine Tranform (DCT) is popularly used to compress images and videos. It

    decomposes an image signal into multiple frequency components. A key ingredient of our solution

    is a suitably adapted and randomized version of Shamirs Secret Sharing scheme. Furthermore, our

    algorithm, unlike most of the video encryption algorithms, has an inbuilt error-tolerance, which

    could be handy in many practical applications.

    2.2.1 ADVANTAGES

    Provides a low cost solution to Encryption and provides good quality video encoding.

    Provides overall high security, size preservation, and relatively fast encryption.

    4

  • 7/27/2019 Video encryption Mini project Content

    5/43

    3. SYSTEM SPECIFICATION

    3.1 HARDWARE REQUIREMENTS

    Processor : Pentium IV

    Speed : Above 500 MHz

    RAM capacity : 1 GB

    Hard disk drive : 80 GB

    Motherboard : Intel

    3.2 SOFTWARE REQUIREMENTS

    Operating System : Windows XP and above

    Technology : MATLAB

    5

  • 7/27/2019 Video encryption Mini project Content

    6/43

    4. SOFTWARE DESCRIPTION

    4.1 MATLAB

    MATLAB is a high-level technical computing language and interactive environment for

    algorithm development, data visualization, data analysis, and numeric computation. Using the

    MATLAB product, one can solve technical computing problems faster than with traditional

    programming languages, such as C, C++, and Fortran.

    One can use MATLAB in a wide range of applications, including signal and image

    processing, communications, control design, test and measurement, financial modeling and

    analysis, and computational biology. Add-on toolboxes extend the MATLAB environment to solve

    particular classes of problems in these application areas.

    MATLAB provides a number of features for documenting and sharing the work. One can

    integrate the MATLAB code with other languages and applications, and distribute the MATLAB

    algorithms and applications.

    6

  • 7/27/2019 Video encryption Mini project Content

    7/43

    4.2 KEY FEATURES

    High-level language for technical computing

    Development environment for managing code, files, and data

    Interactive tools for iterative exploration, design, and problem solving

    Mathematical functions for linear algebra, statistics, Fourier analysis, filtering,

    optimization, and numerical integration

    2-D and 3-D graphics functions for visualizing data

    Tools for building custom graphical user interfaces

    Functions for integrating MATLAB based algorithms with external applications and

    languages, such as C, C++, Fortran, Java, COM, and Microsoft Excel

    Image Processing Toolbox 6.3

    Performs image processing, analysis, and algorithm development

    Image Processing Toolbox software provides a comprehensive set of reference-standard algorithms

    and graphical tools for image processing, analysis, visualization, and algorithm development. One

    can restore noisy or degraded images, enhance images for improved intelligibility, extract features,

    analyze shapes and textures, and register two images. Most toolbox functions are written in the

    open MATLAB language, giving one the ability to inspect the algorithms, modify the source code,

    and create own custom functions.

    Introduction

    Image Processing Toolbox supports engineers and scientists in areas such as biometrics,

    remote sensing, surveillance, gene expression, microscopy, semiconductor testing, image sensor

    7

  • 7/27/2019 Video encryption Mini project Content

    8/43

    design, color science, and materials science. It also facilitates the learning and teaching of image

    processing techniques.

    Key Features

    Image enhancement, including filtering, filter design, deblurring, and contrast enhancement

    Image analysis, including feature detection, morphology, segmentation, and measurement

    Spatial transformations and image registration

    Image transforms, including FFT, DCT, Radon, and fan-beam projection

    Support for multidimensional image processing

    Support for ICC version 4 color management system

    Modular interactive tools, including ROI selections, histograms, and distance measurements

    Interactive image and video display

    DICOM import and export

    8

  • 7/27/2019 Video encryption Mini project Content

    9/43

    5. PROJECT DESCRIPTION

    5.1 PROBLEM DEFINITION

    The rapid growth of Internet and digitized content has made video distribution easy. Hence

    the need for video data protection is on the rise. A secure and computationally feasible video

    encryption algorithm based on the method of Secret Sharing is proposed for use. In an MPEG

    video, the strength of the DC is distributed among the AC values based on Shamirs Secret Sharing

    (SSS) scheme. The proposed algorithm guarantees security, speed and error tolerance with a small

    increase in video size.

    5.2 OVERVIEW OF THE PROJECT

    The overview of the project is to propose a secure and computationally feasible video

    encryption algorithm based on the method of Secret Sharing. In an MPEG video, the strength of the

    DC is distributed among the AC values based on Shamirs Secret Sharing (SSS) scheme. The

    proposed algorithm guarantees security, speed and error tolerance with a small increase in video

    size. There is a need for a new secure video encryption algorithm perhaps designed by combining

    these two classes, which retains their respective advantages, while minimizing the disadvantages.

    We propose a selective cum light-weight encryption algorithm which is fast enough for real-time

    applications, yet possessing practically acceptable levels of security. Discrete Cosine Tranform

    (DCT) is popularly used to compress images and videos. It decomposes an image signal into

    9

  • 7/27/2019 Video encryption Mini project Content

    10/43

    multiple frequency components. A key ingredient of our solution is a suitably adapted and

    randomized version of Shamirs Secret Sharing scheme.

    5.3 MODULE DESCRIPTION

    The project has the following module implementations

    1. Implementation of Discrete Cosine Transform (DCT) to compress the Video

    2. Encryption and Secret Sharing by Shamirs secret sharing scheme

    3. Decryption Process

    4. Compute Error Tolerance

    5. Performance Evaluation

    5.3.1 MODULES

    1. Implementation of Discrete Cosine Transform (DCT) to compress the Video

    In this module, we implement the Discrete Cosine Transform (DCT) to compress images

    and videos. It decomposes an image signal into multiple frequency components. The transform

    coefficients can be classified into two groups namely, DC and AC coefficients. The DC coefficient

    is the mean value of the image block and carries most of the energy in the image block. The AC

    coefficients (ACs) carry energy depending on the amount of detail in the image block. In practice,

    most of the energy is compacted in the DC coefficient and a few AC coefficients.

    2. Encryption and Secret Sharing by Shamirs secret sharing scheme

    In this module, Shamirs (k, n) secret sharing scheme is used, where n = k + 1. The value of

    k varies from 4 to 12 depending on the number of ACs in that block. Though the DC can be shared

    among all the ACs available, it has the drawback of increase in video size as well as the decryption

    10

  • 7/27/2019 Video encryption Mini project Content

    11/43

    time at the receiver. This algorithm is a selective and light-weight encryption algorithm. It takes the

    DC component of each DCT block. Depending on the number of ACs in that block it distributes

    the DC among the ACs and itself, based on the method of secret sharing.

    3. Decryption Process

    In this module, during decryption at the receiver end, the authorized user first has to

    generate a set of random numbers using the key (seed) as the input to PRNG and then proceed with

    constructing k equations from n values. Then use LaGranges interpolation to get back the DC and

    AC coefficients of each block. Even if receiver loses nk values (only one value in the current

    setting), he can retrieve all the DCT coefficients correctly. An unauthorized user cannot get back

    the secret because of the property that any k 1 shares doesnt reveal anything about the secret.

    3. Compute Error Tolerance

    In this module, the Secret Sharing is the key factor that helps in providing error tolerance.

    In the proposed algorithm, k values are distributed among k + 1 values. So, loss or change of one

    value can be tolerated. This feature of the algorithm comes with extra computational overhead

    which is also tolerable. If a value is lost, rest of the k values can be used to get back the original

    coefficients according to secret sharing. If a value is modified, the original values can be obtained

    by trial-and-error in at most k 1 iterations. Hence error-tolerance is achieved.

    4. Performance Analysis

    In this module, the proposed algorithm is evaluated for the following:

    Security of the proposed encryption technique and

    The process of achieving error tolerance.

    11

  • 7/27/2019 Video encryption Mini project Content

    12/43

    5.4 DATA FLOW DIAGRAM

    LEVEL 0

    Figure 1. DFD level 0

    12

    User

    A novel video

    encryption

    technique basedon secret

    sharing

    User

  • 7/27/2019 Video encryption Mini project Content

    13/43

    LEVEL 1

    Figure 2. DFD level 1

    13

    Video

    User

    Compress the

    video by DCT

    Encryption andSecret Sharing by

    Shamirs secretsharing scheme

    Compute Error

    Tolerance

    Decryption

    User

  • 7/27/2019 Video encryption Mini project Content

    14/43

    5.5 INPUT DESIGN

    Input design is the part of overall system design which requires very careful attention. Often

    the collection of input data is the most expensive part of the system, in terms of both the equipment

    used and the number of people involved; it is the point of most contact for the users with the

    computer system; and it is prone to error. If data going into the system are incorrect, then the

    processing and output will magnify these errors.

    Input design is the very important part in the project and should be concentrated well as it is

    prone to error. The data that are to be inserted are to be inserted with care as this plays a very

    important role. In order to get the meaningful output and to achieve good accuracy the input should

    be acceptable and understandable by the user.

    There are various approaches for entering data through terminals. This project is implemented as a

    MATLAB application. The essential things that are considered during input design are:

    The content of the input records: Data items from the inputs will be used to produce the

    output.

    Design of the source document: Source data is usually recorded in order to standardize

    the format of input data. Properly designed source documents also aid accuracy and

    checking procedures.

    User interface design: User input is usually through keyboard and mouse.

    Volume and frequency of input: This will dictate the method of input. Usually small

    volumes of data are input using VDU and thus here too it is input using VDU, validated and

    processed immediately.

    14

  • 7/27/2019 Video encryption Mini project Content

    15/43

    5.6 OUTPUT DESIGN

    Output design plays a very important role in a system. Getting a correct output is a task that

    has to be concentrated, as a system is validated as a correct one only if it gives the correct output

    according to the input.

    Computer output is the most important and direct source of information to the user.

    Efficient and intelligent output design should improve the systems relationship with the user and

    helps in decision making. The output devices depend on factors such as compatibility of the device

    with the system, response time, requirements and so on.

    15

  • 7/27/2019 Video encryption Mini project Content

    16/43

    6. SYSTEM TESTING

    6.1 UNIT TESTING

    Unit testing is the testing of individual hardware or software units or groups of related unit.

    Using white box testing techniques, testers verify that the code does what it is intended to do at a

    very low structural level. For example, the tester will write some test code that will call a method

    with certain parameters and will ensure that the return value of this method is as expected. Looking

    at the code itself, the tester might notice that there is a branch (an if-then) and might write a second

    test case to go down the path not executed by the first test case. When available, the tester will

    examine the low-level design of the code; otherwise, the tester will examine the structure of the

    code by looking at the code itself. Unit testing is generally done within a class or a component.

    6.2 ACCEPTANCE TESTING

    After functional and system testing, the product is delivered to a customer and the customer

    runs black box acceptance tests based on their expectations of the functionality. Acceptance testing

    is formal testing conducted to determine whether or not a system satisfies its acceptance criteria

    (the criteria the system must satisfy to be accepted by a customer) and to enable the customer to

    determine whether or not to accept the system. These tests are often pre-specified by the customer

    and given to the test team to run before attempting to deliver the product. The customer reserves

    the right to refuse delivery of the software if the acceptance test cases do not pass. However,

    customers are not trained software testers. Customers generally do not specify a complete set of

    acceptance test cases. Their test cases are no substitute for creating our own set of

    functional/system test cases. The customer is probably very good at specifying at most one good

    16

  • 7/27/2019 Video encryption Mini project Content

    17/43

    test case for each requirement. Whenever possible, we should run customer acceptance test cases

    ourselves so that we can increase our confidence that they will work at the customer location.

    PROGRAM TESTING

    A program represents the logical elements of a system. For a program to run

    satisfactorily, it must compile and test data correctly and tie in properly with other

    programs. Achieving an error free program is the responsibility of the programmer. Program

    testing checks for two types of errors: syntax and logical. Syntax error is a program

    statement that violates one or more rules of the language in which it is written. An

    improperly defined field dimension or omitted keywords are common syntax errors. These errors

    are shown through error message generated by the computer. For Logic errors the programmer

    must examine the output carefully.

    When a program is tested, the actual output is compared with the expected output.

    When there is a discrepancy the sequence of instructions must be traced to determine the

    problem. The process is facilitated by breaking the program into self-contained portions,

    each of which can be checked at certain key points .The idea is to compare program

    values against desk-calculated values to isolate the problems.

    FUNCTIONAL TESTING

    Functional testing of an application is used to prove the application delivers correct results,

    using enough inputs to give an adequate level of confidence that will work correctly for all sets of

    17

  • 7/27/2019 Video encryption Mini project Content

    18/43

    inputs. The functional testing will need to prove that the application works for each client type and

    that personalization function work correctly.

    Test case no Description Expected result

    1 Test for all modules All module should

    communicate in the

    application.

    2 Test for every functions in a framework

    as it display all results.

    The result after execution

    should give the accurate

    result.NON-FUNCTIONAL TESTING

    This testing is used to check that an application will work in the operational environment.

    Non-functional testing includes:

    Load testing

    Performance testing

    Usability testing

    Reliability testing

    LOAD TESTING

    Test case no Description Expected result

    1 It is necessary to ascertain that the

    application behaves correctly under

    loads of all the components.

    Should display error

    message for particular

    components.

    PERFORMANCE TESTING

    18

  • 7/27/2019 Video encryption Mini project Content

    19/43

    Test case no Description Expected result

    1 This is required to assure that an

    application perforce adequately, having

    the capability to handle many peers,

    delivering its results in expected time

    and using an acceptable level of resource

    and it is an aspect of operational

    management.

    Should handle large input

    values, and produce

    accurate result in a

    expected time

    RELIABILITY TESTING

    Test case no Description Expected result

    1 This is to check that the system is rugged

    and reliable and can handle the failure of

    any of the components involved in

    provide the application.

    In case of failure of the

    system an error handling

    function should take over

    the process

    7. SYSTEM IMPLEMENTATION

    System implementation is the important stage of project when the theoretical design is tuned

    into practical system. The main stages in the implementation are as follows:

    19

  • 7/27/2019 Video encryption Mini project Content

    20/43

    Planning

    System testing and

    Changeover Planning

    Planning is the first task in the system implementation. Planning means deciding on the

    method and the time scale to be adopted. At the time of implementation of any system people from

    different departments and system analysis involve. They are confirmed to practical problem of

    controlling various activities of people outside their own data processing departments. The line

    managers are controlled through an implementation coordinating committee. The committee

    considers ideas, problems and complaints of user department, it must also consider:

    The implication of system environment;

    Self selection and allocation for implementation tasks;

    Consultation with unions and resources available;

    Standby facilities and channels of communication

    RESULTS

    Since the Office Management is a system, which is to be accessed, only by the company

    management alone only one user should design it, in such a way that it should not be flexible

    20

  • 7/27/2019 Video encryption Mini project Content

    21/43

    enough to access at a time. Hence the implementation method used in the system is a pilot type of

    implementation.

    IMPLEMENTATION PROCEDURES

    The implementation plan consists of the methods for changing from the old system to new

    one. There are several methods available for handling the implementation and consequent

    conversion from old to the new computerization system. The most secure method for converting

    from the old to the new system is to run both old and new systems in parallel. In this approach

    personal may operate in the manual order processing system in the accustomed manner as well as

    start operating the new computerization system. This method offers high security, because even if

    there is a flaw in the computerization system we can depend on the manual system. However, the

    cost for maintaining two systems in parallel is very high.

    Another commonly used method is a direct cutter from the existing system to the proposed

    system. The change may be within a week or within a day. There are no parallel activities.

    However, there is no remedy in case of a problem. This strategy requires careful planning.

    We can also implement a working version of the system in one part of the organization and

    the personal will be piloting the system and changes can be made as and when required. But this

    method is less preferable due to the loss of entire system.

    OPERATIONAL DOCUMENTATION

    An Operational Manual is used as a permanent reference document to inform the computer

    operations department to implement the work to be done in routine operation and any special

    21

  • 7/27/2019 Video encryption Mini project Content

    22/43

    features. The manual is the formal communication of system details to the operations department,

    but is not the only communication needed. It is essential that provisional details be supplied to the

    operations department as soon as they are available to give opportunity for preparation of

    preliminary schedules and forward loading plans and for training and familiarization. The contents

    should be clear and practical. As it may be necessary for the manual to be partitioned to the

    requirements, its structure should be determined in consultation with the operations developer.

    IMPLEMENTATION STEP

    The Discrete Cosine Transform (DCT) is implemented to compress images and videos. It

    decomposes an image signal into multiple frequency components. The transform

    coefficients can be classified into two groups namely, DC and AC coefficients. The DC

    coefficient is the mean value of the image block and carries most of the energy in the image

    block. The AC coefficients (ACs) carry energy depending on the amount of detail in the

    image block. In practice, most of the energy is compacted in the DC coefficient and a few

    AC coefficients.

    Shamirs (k, n) secret sharing scheme is used, where n = k + 1. The value of k varies from 4

    to 12 depending on the number of ACs in that block. Though the DC is shared among all

    the ACs available, it has the drawback of increase in video size as well as the decryption

    time at the receiver. This algorithm is a selective and light-weight encryption algorithm. It

    takes the DC component of each DCT block. Depending on the number of ACs in that

    block distributes the DC among the ACs and itself, based on the method of secret sharing.

    22

  • 7/27/2019 Video encryption Mini project Content

    23/43

    During decryption at the receiver end, the authorized user first has to generate a set of

    random numbers using the key (seed) as the input to PRNG and then proceed with

    constructing k equations from n values then use Legranges interpolation to get back the

    DC and AC coefficients of each block. Even if receiver loses nk values (only one value in

    the current setting), he can retrieve all the DCT coefficients correctly. An unauthorized user

    cannot get back the secret because of the property that any k 1 shares doesnt reveal

    anything about the secret.

    The Secret Sharing is the key factor that helps in providing error tolerance. In the proposed

    algorithm, k values are distributed among k + 1 values. So, loss or change of one value can

    be tolerated. This feature of the algorithm comes with extra computational overhead which

    is also tolerable. If a value is lost, rest of the k values can be used to get back the original

    coefficients according to secret sharing. If a value is modified, the original values can be

    obtained by trial-and-error in at most k 1 iterations. Hence error-tolerance is achieved.

    8. CONCLUSION

    8.1 CONCLUSION

    23

  • 7/27/2019 Video encryption Mini project Content

    24/43

    In this project, a novel selective and light-weight encryption algorithm for the security of

    video data is proposed based on the method of sharing the DC coefficients among the ACs and DC.

    Security analysis and experimental results show that the proposed encryption scheme is fast,

    provides good security with error tolerance and adds very less overhead on the compression of the

    video which most of the real-time video applications require. The Discrete Cosine Transform

    (DCT) is implemented to compress images and videos. Then Shamirs (k, n) secret sharing scheme

    is used, where n = k + 1. The value of k varies from 4 to 12 depending on the number of ACs in

    that block. The proposed algorithm increases the video size by 30.23% which is less when

    compared to XOR and scramble algorithms. Though the DC is shared among all the ACs available,

    it has the drawback of increase in video size as well as the decryption time at the receiver.

    8.2 FUTURE ENHANCEMENT

    The future scope is to extend this system to adapt the algorithm for different resolution

    videos, different video formats and highly sensitive videos where every part of the video is

    important. Furthermore the encryption time can be reduced so that it can be used to support large

    video applications.

    9. APPENDIX-1

    9.1 Source code

    Encrypt.m:

    24

  • 7/27/2019 Video encryption Mini project Content

    25/43

    function varargout = final(varargin)

    gui_Singleton = 1;

    gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...

    'gui_OpeningFcn', @final_OpeningFcn, ...

    'gui_OutputFcn', @final_OutputFcn, ...'gui_LayoutFcn', [] , ...

    'gui_Callback', []);

    if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});

    end

    if nargout

    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else

    gui_mainfcn(gui_State, varargin{:});

    end

    function final_OpeningFcn(hObject, eventdata, handles, varargin)handles.output = hObject;

    guidata(hObject, handles);function varargout = final_OutputFcn(hObject, eventdata, handles)

    varargout{1} = handles.output;

    function popupmenu1_Callback(hObject, eventdata, handles)function popupmenu1_CreateFcn(hObject, eventdata, handles)

    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

    set(hObject,'BackgroundColor','white');

    endfunction pushbutton1_Callback(hObject, eventdata, handles)

    clc;

    warning off all;if(isdir('frames'))

    rmdir('frames','s');

    endmkdir('frames');

    switch get(handles.popupmenu1,'Value')

    case 1

    case 2im='Input\human.avi';

    case 3

    im='Input\viptraffic.avi';case 4

    im='Input\hockey ground.avi';

    case 5im='Input\xylo.avi';

    end

    xyloObj = mmreader(im)

    file=im;

    25

  • 7/27/2019 Video encryption Mini project Content

    26/43

    mov=[];

    pickind = 'tif';

    pathname = 'frames\';f=xyloObj.Numberofframes;

    for k = 1 : f

    mov{k} = read(xyloObj, k);strtemp=strcat(pathname,int2str(k),'.',pickind);

    imwrite(mov{k},strtemp);

    endfigure('name','Input video','numbertitle','off')

    for k = 1 : f

    imshow(mov{k});

    hold onpause(0.05)

    end

    im=[];

    block=[];dct_block=[];

    idc=[];[m n p]=size(mov{1});

    h=waitbar(0,'Applying DCT');

    for t=1:fwaitbar(t/f)

    strtemp=strcat(pathname,int2str(t),'.',pickind);

    im{t}=imread(strtemp);

    c2= mat2cell(im{t}, 10*ones(1, (m/10)), 10*ones(1, (n/10)),3);block{t}=c2;

    d=[];id1=[];

    for i=1:size(c2,1)for j=1:size(c2,2)

    x=c2{i,j};

    for p=1:3d1(:,:,p)=dct2(x(:,:,p));

    id(:,:,p)=idct2(d1(:,:,p));

    end

    d{i,j}=d1;id1{i,j}=id;

    end

    enddct_block{t}=d;

    idc{t}=id1;

    endclose(h)

    disp('Blocks')

    disp(block)

    disp('DCT-Blocks')

    26

  • 7/27/2019 Video encryption Mini project Content

    27/43

    disp(dct_block)

    h1=waitbar(0,'Encrypting the frames');

    en_bl=[];r1=rand(1);r2=rand(1);

    save po1 r1 r2

    r1=rand(1);r2=rand(1);save po2 r1 r2

    r1=rand(1);r2=rand(1);

    save po3 r1 r2ienk=[];

    alk=[];

    q=0;q1=0;q2=0;

    for t=1:ftic

    waitbar(t/f)

    d2=dct_block{t};

    en=[];ien=[];for i=1:size(c2,1)

    for j=1:size(c2,2)d3=d2{i,j};

    for p=1:3

    d4=d3(:,:,p);dc=d4(1,1);

    a=find(d4>0);

    if(a(1)==1)

    a1=length(a)-1;else

    a1=length(a);

    endal(i,j)=a1;

    if(a15)

    z=1;dk=subfun(z,d4,a1);

    q=q+1;

    elseif(a1>=10 && a120)z=3;

    dk=subfun(z,d4,a1);

    q2=q2+1;end

    ak(:,:,p)=dk;

    ek(:,:,p)=idct2(dk);

    end

    27

  • 7/27/2019 Video encryption Mini project Content

    28/43

    en{i,j}=ak;

    ien{i,j}=ek;

    endend

    en_bl{t}=en;

    ienk{t}=ien;alk{t}=al;

    ti(t)=toc;

    endclose(h1)

    disp('Encrypted Blocks')

    disp( en_bl)

    if(isdir('en_frames'))rmdir('en_frames','s');

    end

    mkdir('en_frames');

    pathname1 = 'en_frames\';for i=1:f

    strtemp1=strcat(pathname1,int2str(i),'.',pickind);enp=en_bl{i};

    imwrite(cell2mat(enp),strtemp1);

    endname1='encrypted.avi';

    aviobj = avifile(name1);

    path='en_frames\';

    fram2mov('en_frames\*.tif',aviobj,name1,path)save fi1 file

    save ti1 ti

    save alk1 alksave ftt f

    save dcb dct_block

    save cc c2save mov1 mov

    function pushbutton2_Callback(hObject, eventdata, handles)

    load alk1

    load fttload dcb

    load cc

    load mov1pickind = 'tif';

    ii=decryp(alk,f,dct_block,c2);

    if(isdir('de_frames'))rmdir('de_frames','s');

    end

    mkdir('de_frames');

    pathname2= 'de_frames\';

    28

  • 7/27/2019 Video encryption Mini project Content

    29/43

    for i=1:f

    strtemp2=strcat(pathname2,int2str(i),'.',pickind);

    imwrite(uint8(ii{i}),strtemp2);end

    name2='decrypted.avi';

    aviobj1 = avifile(name2);path1='de_frames\';

    fram2mov('de_frames\*.tif',aviobj1,name2,path1)

    for i=1:fk1=mov{i};

    k2=uint8(ii{i});

    er(i)=mean(mean(mean((k1-k2))))/100;

    endsave er1 er

    function pushbutton3_Callback(hObject, eventdata, handles)

    load fi1

    load er1load ti1

    fileinfo = aviinfo(file);fileinfo1 = aviinfo('encrypted.avi');

    v1=fileinfo.FileSize/1024;

    v2=fileinfo1.FileSize/1024;figure('name','Comparison by size','numbertitle','off')

    bar(3,v1,'r');

    hold on

    bar(6,v2,'m');axis([1 10 0 max(v1,v2)+200])

    xlabel('Videos')

    ylabel('Size (Bytes)')legend('Original','Encrypted')

    figure('name','Time For Encryption','numbertitle','off')

    plot(1:length(ti),ti,'m');xlabel('Different frames')

    ylabel('Time (Sec)')

    figure('name','Error For Encryption','numbertitle','off')

    plot(1:length(er),er,'r');xlabel('Different frames')

    ylabel('Error')

    function pushbutton4_Callback(hObject, eventdata, handles)

    close all;

    clc;

    subfunction.m:

    function dk=subfun(z,d4,a1)

    29

  • 7/27/2019 Video encryption Mini project Content

    30/43

    if(z==1)

    dk=d4;

    r=4;load po1;

    acn=d4(a1);

    dk(1)=poly(d4,r1);dk(1,2)=poly(d4,r2);

    dk(1,3)=poly(d4,2);

    dk(1,4)=poly(d4,3);dk(a1)=poly(d4,a1);

    end

    if(z==2)

    dk=d4;r=8;

    load po2;

    dk(1)=poly1(d4,r1);

    dk(1,2)=poly1(d4,r2);dk(1,3)=poly1(d4,2);

    dk(1,4)=poly1(d4,3);dk(1,5)=poly1(d4,4);

    dk(1,6)=poly1(d4,5);

    dk(1,7)=poly1(d4,6);dk(1,8)=poly1(d4,7);

    dk(a1)=poly1(d4,a1);

    end

    if(z==3)dk=d4;

    r=8;

    load po3;acn=d4(a1);

    dk(1)=poly2(d4,r1);

    dk(1,2)=poly2(d4,r2);dk(1,3)=poly2(d4,2);

    dk(1,4)=poly2(d4,3);

    dk(1,5)=poly2(d4,4);

    dk(1,6)=poly2(d4,5);dk(1,7)=poly2(d4,6);

    dk(1,8)=poly2(d4,7);

    dk(1,9)=poly2(d4,8);dk(1,10)=poly2(d4,9);

    dk(2,1)=poly2(d4,10);

    dk(2,2)=poly2(d4,11);dk(a1)=poly2(d4,a1);

    end

    function f=poly(d4,x)

    dc=d4(1);

    30

  • 7/27/2019 Video encryption Mini project Content

    31/43

    ac1=d4(1,2);ac2=d4(1,3);ac3=d4(1,4);

    f1=ac3*(x^3)+ac2*(x^2)+ac1*(x^1)+dc;

    f=mod(f1,251);function f=poly1(d4,x)

    dc=d4(1);

    ac1=d4(1,2);ac2=d4(1,3);ac3=d4(1,4);ac4=d4(1,5);ac5=d4(1,6);ac6=d4(1,7);ac7=d4(1,8) ;f1=ac7*(x^7)+ac6*(x^6)+ac5*(x^5)+ac4*(x^4)+ac3*(x^3)+ac2*(x^2)+ac1*(x^1)+dc;

    f=mod(f1,251);

    function f=poly2(d4,x)dc=d4(1);

    ac1=d4(1,2);ac2=d4(1,3);ac3=d4(1,4);ac4=d4(1,5);ac5=d4(1,6);ac6=d4(1,7);ac7=d4(1,8);ac8=d4(1

    ,9);ac9=d4(1,10);ac10=d4(2,1);ac11=d4(2,2);

    f1=ac11*(x^11)+ac10*(x^10)+ac9*(x^9)+ac8*(x^8)+ac7*(x^7)+ac6*(x^6)+ac5*(x^5)+ac4*(x^4)

    +ac3*(x^3)+ac2*(x^2)+ac1*(x^1)+dc;

    f=mod(f1,251);

    Frames2movie.m:

    function fram2mov(dname,aviobj,name,path)

    dirData = dir(dname)% dirData =dir(dname);

    fileNames = {dirData.name};

    l=length(fileNames);

    for i=1:l[a, map] = imread(strcat(strcat(path,int2str(i),'.tif')));

    M = im2frame(a);

    aviobj = addframe(aviobj,M);end

    disp('Closing movie file...')

    aviobj = close(aviobj);%play the movie

    disp('Playing movie file...')

    implay(name);

    decrypt.m:

    % decryption

    function ii=decryp(alk,f,dc,c2)ii=[];

    for t=1:f

    w=alk{t};

    d2=dc{t};

    31

  • 7/27/2019 Video encryption Mini project Content

    32/43

    id1=[];

    for i=1:size(c2,1)

    for j=1:size(c2,2)w1=w(i,j);

    if(w1>30)

    x=d2{i,j};for p=1:3

    ui(:,:,p)=idct2(x(:,:,p));

    endid1{i,j}=ui;

    else

    id1{i,j}=d2{i,j};

    endend

    end

    ii{t}=cell2mat(id1);

    end

    10.APPENDIX-2

    SCREEN SHOTS

    1.Main page

    32

  • 7/27/2019 Video encryption Mini project Content

    33/43

    2.Applying DCT:

    Video is given as input to the DCT function.

    33

  • 7/27/2019 Video encryption Mini project Content

    34/43

    3.Encrypting frames

    The frames are encrypted using Secret Sharing algorithm.

    34

  • 7/27/2019 Video encryption Mini project Content

    35/43

    4.Encrypted video

    The encrypted frames are converted to movie file format.

    35

  • 7/27/2019 Video encryption Mini project Content

    36/43

    5.Encrypted frames:

    Images of encrypted frames.

    36

  • 7/27/2019 Video encryption Mini project Content

    37/43

    6.Decrypted video

    The encrypted video is decrypted by reverse process of encryption.

    37

  • 7/27/2019 Video encryption Mini project Content

    38/43

    7.Decrypted frames

    Images of the decrypted frames.

    38

  • 7/27/2019 Video encryption Mini project Content

    39/43

    8.Comparison by Size

    The comparison is made between original video and encrypted video.

    39

  • 7/27/2019 Video encryption Mini project Content

    40/43

    9.Time taken for encryption

    Time taken for each frame for encryption is calculated and plotted.

    40

  • 7/27/2019 Video encryption Mini project Content

    41/43

    10.Error for encryption

    The difference between original video and decrypted video is calculated.

    41

  • 7/27/2019 Video encryption Mini project Content

    42/43

    11. REFERENCES

    42

  • 7/27/2019 Video encryption Mini project Content

    43/43

    [1] L. Tang, Methods for encrypting and decrypting MPEG video data efficiently, in Proc. of

    ACM Multimedia, pp. 219229.

    [2] L. Qiao and Klara Nahrstedt, A new algorithm for MPEG video encryption, in Proc. of First

    International Conference on Imaging Science System and Technology, 1997, pp. 2129.

    [3] Wenjun Zeng and Shawmin Lei, Efficient frequency domain selective scrambling of digital

    video, in Proc. of the IEEE Transactions on Multimedia, 2002, pp. 118129.

    [4] Zhenyong Chen, Zhang Xiong, and Long Tang, A novel scrambling scheme for digital video

    encryption, in Proc. of Pacific-Rim Symposium on Image and Video Technology( PSIVT), 2006,

    pp. 9971006.

    [5] B. Furht and D. Kirovski, Multimedia Security Handbook, CRC Press LLC, 2004.

    [6] C. Shi and Bharat Bhargava, A fast MPEG video encryption algorithm, in Proc. of ACM

    Multimedia, 1998, pp. 8188.

    [7] A. Shamir, How to share a secret, in Proc. of Communications of the ACM, 1979, vol. II, pp.

    612613.

    [8] Zheng Liu, Xue Li, and Zhaoyang Dong, Enhancing security of frequency domain video

    encryption, in Proc. of ACM Multimedia, 2004, pp. 304307.

    [9] J. Meyer and F. Gadegast, Security mechanisms for multimedia data with the example MPEG-

    1 video, available at www.gadegast.de/frank/doc/secmeng.pdf.

    [10] Wei-Tsang Ooi, Brian Smith, Sugata Mukhopadhyay, Haye Hsi Chan, SteveWeiss,Matthew

    Chiu, and Jiesang Song, The DALI multimedia software library, in SPIE Multimedia Computing

    and Networking, 1999.