p = Prime[6]
q = Prime[8]
n = p q
e = Prime[10]
d = PowerMod[e,-1,(p-1)(q-1)]

unknownmsg = 81;
c = PowerMod[unknownmsg, e, n]
PowerMod[c,d,n]

thr = 2^7-0.5;
Mod[c* PowerMod[2^Range[1,8],e,n],n]
(1+Sign[PowerMod[c *PowerMod[2^Range[1,8],e,n],d,n]-thr])/2

DiscretePlot[{(1+Sign[Mod[i*2,n]-thr])/2 +(1-Sign[Mod[i*4,n]-thr])/2+(1+Sign[Mod[i*8,n]-thr])/2+(1-Sign[Mod[i*16,n]-thr])/2+(1-Sign[Mod[i*32,n]-thr])/2 + (1+Sign[Mod[i*64,n]-thr])/2 + (1+Sign[Mod[i*128,n]-thr])/2+(1+Sign[Mod[i*256,n]-thr])/2 }, {i,0,246}]

DiscretePlot[{(1+Sign[Mod[i*2,n]-thr])/2 +(1-Sign[Mod[i*4,n]-thr])/2+(1+Sign[Mod[i*8,n]-thr])/2+(1-Sign[Mod[i*16,n]-thr])/2+(1-Sign[Mod[i*32,n]-thr])/2 + (1+Sign[Mod[i*64,n]-thr])/2 + (1+Sign[Mod[i*128,n]-thr])/2+(1+Sign[Mod[i*256,n]-thr])/2 }, {i,78,86}]