Thread Subject:
video encryption

Subject: video encryption

From: Sheraz ahmad

Date: 3 Dec, 2010 07:55:06

Message: 1 of 9

I want to encrypt MPEG video,so i need encryption code.

Subject: video encryption

From: Walter Roberson

Date: 3 Dec, 2010 20:30:27

Message: 2 of 9

On 10-12-03 01:55 AM, Sheraz ahmad wrote:
> I want to encrypt MPEG video,so i need encryption code.

Supposing I is the 2D image and it is in uint8 format, then:

encryption_key = 'Now is the time for the proles to rise up and seize the
means of chocolate production!'

encrypting_bytes = ...
encryption_key(1 + mod(1:length(numel(I)),length(encryption_key));

encrypted_I = bitxor(I, encrypting_bytes');


To decrypt, pass the encrypted data through exactly the same routine.

Subject: video encryption

From: Thanh

Date: 6 Dec, 2010 06:45:08

Message: 3 of 9

Walter Roberson <roberson@hushmail.com> wrote in message <idbk16$t7d$1@canopus.cc.umanitoba.ca>...
> On 10-12-03 01:55 AM, Sheraz ahmad wrote:
> > I want to encrypt MPEG video,so i need encryption code.
>
> Supposing I is the 2D image and it is in uint8 format, then:
>
> encryption_key = 'Now is the time for the proles to rise up and seize the
> means of chocolate production!'
>
> encrypting_bytes = ...
> encryption_key(1 + mod(1:length(numel(I)),length(encryption_key));
>
> encrypted_I = bitxor(I, encrypting_bytes');
>
>
> To decrypt, pass the encrypted data through exactly the same routine.

i have a question, when i run the code, Matlab notifies:
??? Error using ==> bitxor
Operands to BIT Ops must be numeric.
what's the problem and how to fix it ???

Subject: video encryption

From: Walter Roberson

Date: 6 Dec, 2010 07:19:40

Message: 4 of 9

On 06/12/10 12:45 AM, Thanh wrote:
> Walter Roberson <roberson@hushmail.com> wrote in message
> <idbk16$t7d$1@canopus.cc.umanitoba.ca>...
>> On 10-12-03 01:55 AM, Sheraz ahmad wrote:
>> > I want to encrypt MPEG video,so i need encryption code.
>>
>> Supposing I is the 2D image and it is in uint8 format, then:
>>
>> encryption_key = 'Now is the time for the proles to rise up and seize
>> the means of chocolate production!'
>>
>> encrypting_bytes = ...
>> encryption_key(1 + mod(1:length(numel(I)),length(encryption_key));
>>
>> encrypted_I = bitxor(I, encrypting_bytes');
>>
>>
>> To decrypt, pass the encrypted data through exactly the same routine.
>
> i have a question, when i run the code, Matlab notifies:
> ??? Error using ==> bitxor
> Operands to BIT Ops must be numeric.
> what's the problem and how to fix it ???

Sorry, I had some typos there and missed a step.

encryption_key = 'Now is the time for the proles to rise up and seize
the means of chocolate production!';

encrypting_bytes = ...
reshape(uint8(encryption_key(1+mod(0:numel(I)-1,length(encryption_key)))),size(I));

encrypted_I = bitxor(I, encrypting_bytes);

Subject: video encryption

From: Thanh

Date: 6 Dec, 2010 07:48:04

Message: 5 of 9

Walter Roberson <roberson@hushmail.com> wrote in message <h80Lo.34$zh.0@newsfe13.iad>...
> On 06/12/10 12:45 AM, Thanh wrote:
> > Walter Roberson <roberson@hushmail.com> wrote in message
> > <idbk16$t7d$1@canopus.cc.umanitoba.ca>...
> >> On 10-12-03 01:55 AM, Sheraz ahmad wrote:
> >> > I want to encrypt MPEG video,so i need encryption code.
> >>
> >> Supposing I is the 2D image and it is in uint8 format, then:
> >>
> >> encryption_key = 'Now is the time for the proles to rise up and seize
> >> the means of chocolate production!'
> >>
> >> encrypting_bytes = ...
> >> encryption_key(1 + mod(1:length(numel(I)),length(encryption_key));
> >>
> >> encrypted_I = bitxor(I, encrypting_bytes');
> >>
> >>
> >> To decrypt, pass the encrypted data through exactly the same routine.
> >
> > i have a question, when i run the code, Matlab notifies:
> > ??? Error using ==> bitxor
> > Operands to BIT Ops must be numeric.
> > what's the problem and how to fix it ???
>
> Sorry, I had some typos there and missed a step.
>
> encryption_key = 'Now is the time for the proles to rise up and seize
> the means of chocolate production!';
>
> encrypting_bytes = ...
> reshape(uint8(encryption_key(1+mod(0:numel(I)-1,length(encryption_key)))),size(I));
>
> encrypted_I = bitxor(I, encrypting_bytes);
>
That's alright. Thank you a lot, i've already run this code. But please explain for me what's the purpose of the function " reshape" ?

Subject: video encryption

From: Walter Roberson

Date: 6 Dec, 2010 08:30:15

Message: 6 of 9

On 06/12/10 1:48 AM, Thanh wrote:
> Walter Roberson <roberson@hushmail.com> wrote in message

>> encrypting_bytes = ...
>> reshape(uint8(encryption_key(1+mod(0:numel(I)-1,length(encryption_key)))),size(I));

> explain for me what's the purpose of the function " reshape" ?

0:numel(I)-1 is a vector of values, and the mod() and matrix lookup and
uint8() steps applied keep that form as a vector of values. However, for
the bitxor() to work against the entire image, the second argument for
bitxor needs to be a matrix the same dimensions as the first -- the same
number of rows, columns, and color channels. reshape() takes the vector
of input and reorganizes it as a matrix of appropriate size.

For information as to where the various parts of the vector end up in
the reshaped matrix, please read the documentation about reshape and
about how arrays are stored.

Subject: video encryption

From: Thanh

Date: 7 Dec, 2010 03:01:05

Message: 7 of 9

Walter Roberson <roberson@hushmail.com> wrote in message <wa1Lo.6457$3D2.5368@newsfe20.iad>...
> On 06/12/10 1:48 AM, Thanh wrote:
> > Walter Roberson <roberson@hushmail.com> wrote in message
>
> >> encrypting_bytes = ...
> >> reshape(uint8(encryption_key(1+mod(0:numel(I)-1,length(encryption_key)))),size(I));
>
> > explain for me what's the purpose of the function " reshape" ?
>
> 0:numel(I)-1 is a vector of values, and the mod() and matrix lookup and
> uint8() steps applied keep that form as a vector of values. However, for
> the bitxor() to work against the entire image, the second argument for
> bitxor needs to be a matrix the same dimensions as the first -- the same
> number of rows, columns, and color channels. reshape() takes the vector
> of input and reorganizes it as a matrix of appropriate size.
>
> For information as to where the various parts of the vector end up in
> the reshaped matrix, please read the documentation about reshape and
> about how arrays are stored.

thank you a lot , your answer is very helpful.

Subject: video encryption

From: Florin

Date: 16 Jun, 2012 19:57:07

Message: 8 of 9

"Thanh" wrote in message <idk81h$1sh$1@fred.mathworks.com>...
> Walter Roberson <roberson@hushmail.com> wrote in message <wa1Lo.6457$3D2.5368@newsfe20.iad>...
> > On 06/12/10 1:48 AM, Thanh wrote:
> > > Walter Roberson <roberson@hushmail.com> wrote in message
> >
> > >> encrypting_bytes = ...
> > >> reshape(uint8(encryption_key(1+mod(0:numel(I)-1,length(encryption_key)))),size(I));
> >
> > > explain for me what's the purpose of the function " reshape" ?
> >
> > 0:numel(I)-1 is a vector of values, and the mod() and matrix lookup and
> > uint8() steps applied keep that form as a vector of values. However, for
> > the bitxor() to work against the entire image, the second argument for
> > bitxor needs to be a matrix the same dimensions as the first -- the same
> > number of rows, columns, and color channels. reshape() takes the vector
> > of input and reorganizes it as a matrix of appropriate size.
> >
> > For information as to where the various parts of the vector end up in
> > the reshaped matrix, please read the documentation about reshape and
> > about how arrays are stored.
>
> thank you a lot , your answer is very helpful.





Can you give me please the matlab encryption source code, cause i have to make an encryption for a video file... thanks a lot...

Florin

Subject: video encryption

From: Steven_Lord

Date: 18 Jun, 2012 04:27:25

Message: 9 of 9



"Florin " <just_flow87@yahoo.com> wrote in message
news:jrioej$72b$1@newscl01ah.mathworks.com...

*snip*

> Can you give me please the matlab encryption source code, cause i have to
> make an encryption for a video file... thanks a lot...

No for several reasons including:

http://en.wikipedia.org/wiki/Export_of_cryptography_in_the_United_States

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us