close all
clear all
clc
[s Fs]=audioread('1.wav');
s=s(50001:70000,1);
s=s/max(abs(s));
s=s-min(s);
s=round(s*128); %8bit 量化;
%figure;plot(s); title('原始语音数据');
sound(s);
S=fft(s);
%figure;plot(fftshift(abs(S))); title('原始语音频谱');
N = length(s);
%约瑟夫环:
m=137;
k1=yuesefu(N,m);
figure; plot(k1);title('约瑟夫密钥');
for i=1:N
s2(i)=s(k1(i));
end
%logistic
lambda = 3:5e-4:4;
x = rand(1)*ones(1,length(lambda));
N1 = 400;
N2 = 1000;
f = zeros(N1+N2,length(lambda));
for i = 1:N1+N2
x = lambda .* x .* (1 - x);
f(i,:) = x;
end
f = f(N1+1:end,:);
figure;
plot(lambda,f,'k.','MarkerSize',1)
xlabel('lambda')
ylabel('x');
ss=f(:,1930:end);
ss=reshape(ss,1,72000);
ss=mod(round(1000*ss(1:4000)),256);
figure;plot(ss);title('logistic 密钥');
s3=reshape(s2,5,4000);
for i=1:5
for j=1:4000
s4(i,j)=bitxor(s3(i,j),ss(j));
end
end
%加密完成的数据:
s4=reshape(s4,1,20000);
%解密开始:
%解logistic:
s5=reshape(s4,5,4000);
for i=1:5
for j=1:4000
s6(i,j)=bitxor(s5(i,j),ss(j));
end
end
s6=reshape(s6,1,20000);
%解约瑟夫
for i=1:N
s7(k1(i))=s6(i);
end
figure;
subplot(211);plot(s); title('原始语音数据');
subplot(212);plot(s7);title('解密后的语音');
sound(s7)
S7=fft(s7);
figure;
subplot(211);plot(fftshift(abs(S))); title('原始语音频谱');
subplot(212);plot(fftshift(abs(S7)));title('解密后的语音频谱');