• Create BookmarkCreate Bookmark
• Create Note or TagCreate Note or Tag
• PrintPrint

### 10.6. MATLAB Files

#### 10.6.1. RC4 Encryption

```%Initialize the secret key
MyKey(1)=164;
MyKey(2)=4;
MyKey(3)=24;
MyKey(4)=107;
MyKey(5)=251;
MyKey(6)=66;
MyKey(7)=186;
MyKey(8)=95;
%Initialize data
data=round(rand(1,300)*256);
%Create an array of size 256 filled with numbers from 0 to 255.
for i=1:256
S(i)=i-1;
end
% Create another array of size 256 filled with repetitions of the key.
for i=0:255
K(i+1)=MyKey(mod(i,length(MyKey))+1);
end
% Initialize the order of S according to the secret key.
j=0;
for i=0:255
j=mod(j+S(i+1)+K(i+1),256);
temp=S(i+1);
S(i+1)=S(j+1);
S(j+1)=temp;
end
% The encrypted data is generated one byte at a time.
i=0;
j=0;
for k=1: length(data)
i=mod(i+1, 256);
j=mod(j+S(i+1), 256);
temp=S(i+1);
S(i+1)=S(j+1);
S(j+1)=temp;
t=mod(S(i+1)+S(j+1),256);
PS=S(t+1);
edata(k)=bitxor(data(k),PS);
end

```

#### 10.6.2. Gaussian Filter Coefficients

```% Obtain normalized Gaussian filter coefficients
f3dbT=0.5;
T=1/1e6;
f3db=0.5/T;
alp=0.5887/f3db;
dt=1/5e6;
k=[-5:5];
hg=exp(-(pi^2/alp^2)*dt^2*k.^2);
```

PREVIEW

Not a subscriber?

Start A Free Trial

• Create BookmarkCreate Bookmark
• Create Note or TagCreate Note or Tag
• PrintPrint