function y=F(R,SK)
k=[4 1 2 3 2 3 4 1];%交换顺序
s0=[1 0 3 2
3 2 1 0
0 2 1 3
3 1 3 2];
s1=[0 1 2 3
2 0 1 3
3 0 1 0
2 1 0 3];%S盒
EP=zeros(1,8);
for i=1:8
EP(i)=R(k(i));
end
P=mod(EP+SK,2);
P=num2str(reshape(P,2,4));
Px1=bin2dec(P(1,[1 4]));
Py1=bin2dec(P(1,[2 3]));
Px2=bin2dec(P(2,[1 4]));
Py2=bin2dec(P(2,[2 3]));%产生坐标
y1=s0(Px1+1,Py1+1);
y2=s1(Px2+1,Py2+1);
y=[y1,y2];
y=dec2bin(y,2);
y=reshape(y',1,[]);
y=str2num(y(:));
y=P4(y);
end