ClearAll["Global`*"]

mpm=InputString["Do you want to activate safe mode? Y=yes N=no"];

If[Equal[mpm,"Y"],scc=InputString["Please pick a single ASCII character code called scc"];While[!Equal[StringLength[scc],1],scc=InputString["Please pick a single ASCII character code"]];]

encryption[s_]:=(If[StringQ[s],code=ToCharacterCode[s],Print["Error! Please type your text between quotation marks."]];
max=Length[code];char=Map[IntegerString,code];insert[u_String]:=StringInsert[u,"0",1];
r=1;While[r≤max,
If[StringLength[char[[r]]]==3,char[[r]]=char[[r]],char[[r]]=insert[char[[r]]]];
r++];char;
n=FromDigits[Apply[StringJoin,char]];
number=IntegerDigits[n,2];plus=IntegerDigits[n+1,2];minus=IntegerDigits[n-1,2];
center=Append[PadLeft[number,First[Sort[Map[Length,{number,plus,minus}],Greater]]],0];right=Append[PadLeft[plus,First[Sort[Map[Length,{number,plus,minus}],Greater]]],0];left=Append[PadLeft[minus,First[Sort[Map[Length,{number,plus,minus}],Greater]]],0];j=1;adj=0;seq={};
While[j≤Length[center]-1,
If[j==1&&First[Take[Transpose[{left,center,right}][[j]],{2,2}]]==1,
adj=Count[Transpose[{left,center,right}][[j]],1]+Count[Transpose[{left,center,right}][[j+1]],1]-1];
If[First[Take[Transpose[{left,center,right}][[j]],{2,2}]]==1,adj=Count[Transpose[{left,center,right}][[j-1]],1]+Count[Transpose[{left,center,right}][[j]],1]+Count[Transpose[{left,center,right}][[j+1]],1]-1,adj=0];
seq=Append[seq,adj];
j++];
If[Length[seq]>1&&First[seq]==0,seq=Drop[seq,1],seq=seq];
k=1;rep={};
While[k≤Length[seq],
If[seq[[k]]==0,col={Opacity[0.0],Cuboid[{0,Length[seq]-k,0}]},
Which[seq[[k]]==1,col={Orange,Cuboid[{0,0,0}]},seq[[k]]==2,col={Red,Cuboid[{0,Length[seq]-k,0}],Red,Cuboid[{0,Length[seq]-k,1}]},seq[[k]]==3,col={Green,Cuboid[{0,Length[seq]-k,0}],Green,Cuboid[{0,Length[seq]-k,1}],Green,Cuboid[{0,Length[seq]-k,2}]},seq[[k]]==4,col={Lighter[Purple],Cuboid[{0,Length[seq]-k,0}],Lighter[Purple],Cuboid[{0,Length[seq]-k,1}],Lighter[Purple],Cuboid[{0,Length[seq]-k,2}],Lighter[Purple],Cuboid[{0,Length[seq]-k,3}]},
seq[[k]]==5,col={Yellow,Cuboid[{0,Length[seq]-k,0}],Yellow,Cuboid[{0,Length[seq]-k,1}],Yellow,Cuboid[{0,Length[seq]-k,2}],Yellow,Cuboid[{0,Length[seq]-k,3}],Yellow,Cuboid[{0,Length[seq]-k,4}]},seq[[k]]==6,col={Darker[Green],Cuboid[{0,Length[seq]-k,0}],Darker[Green],Cuboid[{0,Length[seq]-k,1}],Darker[Green],Cuboid[{0,Length[seq]-k,2}],Darker[Green],Cuboid[{0,Length[seq]-k,3}],Darker[Green],Cuboid[{0,Length[seq]-k,4}],Darker[Green],Cuboid[{0,Length[seq]-k,5}]},seq[[k]]==7,
col={Black,Cuboid[{0,Length[seq]-k,0}],Black,Cuboid[{0,Length[seq]-k,1}],Black,Cuboid[{0,Length[seq]-k,2}],Black,Cuboid[{0,Length[seq]-k,3}],Black,Cuboid[{0,Length[seq]-k,4}],Black,Cuboid[{0,Length[seq]-k,5}],Black,Cuboid[{0,Length[seq]-k,6}]},seq[[k]]==8,col={Brown,Cuboid[{0,Length[seq]-k,0}],Brown,Cuboid[{0,Length[seq]-k,1}],Brown,Cuboid[{0,Length[seq]-k,2}],Brown,Cuboid[{0,Length[seq]-k,3}],Brown,Cuboid[{0,Length[seq]-k,4}],Brown,Cuboid[{0,Length[seq]-k,5}],Brown,Cuboid[{0,Length[seq]-k,6}],Brown,Cuboid[{0,Length[seq]-k,7}]}]];
rep=Append[rep,col];
k++];
Graphics3D[rep])

encryption["SOS"]

%//InputForm

clean=Level[%,1];

If[Equal[mpm,"Y"],confirmscc=InputString["Please enter the valid scc"];x=1;While[!Equal[confirmscc,scc]&& x≤ 3,confirmscc=InputString["Please enter the valid scc"];x++];If[x==4,Print["You are only allowed a maximum of three attempts!"] && Interrupt[]];]

decryption[clean_List]:=(chrom=clean;binary={};
q=1;
While[q≤Last[Dimensions[chrom]],
If[Length[Position[chrom[[1,q]],Opacity]]==0,zone=1,zone=0];
binary=Append[binary,zone];
q++];
word=IntegerString[FromDigits[binary,2]];
add[v_String]:=StringInsert[v,"0",1];
If[Mod[StringLength[word],3]==0,word=word,word=add[word]];
h=3;bag={};
While[StringLength[word]>0,
bag=Append[bag,StringTake[word,h]];
word=StringDrop[word,h]];
delete[f_String]:=StringDrop[f,1];
t=1;While[t≤Length[bag],
If[SameQ[StringTake[bag[[t]],1],"0"],bag[[t]]=delete[bag[[t]]],bag[[t]]=bag[[t]];
t++]];
FromCharacterCode[Map[FromDigits,bag]])

decryption[clean]