Welcome Guest [Log In] [Register]
Welcome to Crypto. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
NUMCODING, a substitution encryption scheme between arbitrary alphabets via numerical encoding
Topic Started: Feb 5 2014, 11:10 PM (445 Views)
mok-kong shen
NSA worthy
[ *  *  *  *  *  * ]
Code:
 
#[space]NUMCODING,[space]a[space]substitution[space]encryption[space]scheme[space]between[space]arbitrary[space]and
#[space]arbitrarily[space]sized[space]alphabets[space]via[space]numerical[space]encoding.


#[space]Version[space]1.1,[space]released[space]on[space]16.02.2014.

#[space]Update[space]Notes:

#[space]Version[space]1.0:[space]Released[space]on[space]05.02.2014.
#[space]Version[space]1.1:[space]A[space]redundancy[space]in[space]convnumtext()[space]removed.[space]The[space]examples[space]section
#[space]revised[space]to[space]show[space]the[space]full[space]capabilities[space]of[space]the[space]scheme.

#[space]Available[space]at:[space]http://s13.zetaboards.com/Crypto/topic/7155855/1/

#[space](Code[space]lines[space]of[space]the[space]same[space]date[space]are[space]always[space]identical.[space]There[space]may[space]however[space]be
#[space]interim[space]modifications[space]of[space]comment[space]lines.)

#[space]Constructive[space]critiques[space]and[space]comments[space]are[space]sincerely[space]solicited.

#[space]Email[space]address[space]of[space]the[space]author:[space]mok-kong.shen@t-online.de


#[space]Prologue.

#[space]For[space]substitution[space]encryption[space]in[space]the[space]sense[space]of[space]the[space]classical[space]mono-alphabetical[space]or
#[space]poly-alphabetical[space]substitutions[space]the[space]size[space]of[space]the[space]plaintext[space]alphabet[space]must[space]be
#[space]smaller[space]or[space]equal[space]to[space]the[space]size[space]of[space]the[space]substitution[space]alphabet(s).[space]The[space]following
#[space]code[space]implements[space]in[space]Python[space]a[space]methode,[space]due[space]to[space]WTShaw[space](see[space]remark[space]below),[space]of
#[space]employing[space]numerical[space]encoding[space]--[space]using[space]the[space]common[space]formula[space]of[space]representation[space]of
#[space]integers[space]in[space]a[space]certain[space]base,[space]in[space]our[space]case[space]its[space]value[space]being[space]the[space]size[space]of[space]an
#[space]alphabet[space]employed[space]and[space]the[space]digits[space]being[space]the[space]indices[space]of[space]the[space]characters[space]of[space]a
#[space]given[space]text[space]string[space]in[space]the[space]alphabet[space]--[space]of[space]overcoming[space]this[space]constraint,[space]which
#[space]apparently[space]can[space]be[space]desirable[space]and[space]useful[space]in[space]relevant[space]practical[space]encryption
#[space]processing.[space]Note[space]that,[space]as[space]a[space]consequence[space]of[space]the[space]specific[space]transformations
#[space]involved,[space]the[space]resulting[space]substitution[space]cannot[space]in[space]general[space]be[space]equivalently
#[space]expressed[space]in[space]terms[space]of[space]the[space]classical[space]mono-alphabetical[space]or[space]poly-alphabetical
#[space]substitutions,[space]which[space]could[space]be[space]regarded[space]as[space]a[space]complexity[space]advantageous[space]in
#[space]security[space]aspects[space]in[space]our[space]view.

#[space]It[space]may[space]be[space]remarked[space]though[space]that[space]WTShaw's[space]own[space]work[space]hithertofore[space]had
#[space]unfortunately[space]an[space]essential[space]problem[space]that[space]he[space]overlooked,[space]thus[space]rendering[space]his
#[space]proposal,[space]rigorously[space]speaking,[space]incorrect[space](see[space]discussions[space]in[space][1]).[space]The[space]simple,
#[space]in[space]fact[space]trivial,[space]solution[space]to[space]that[space]that[space]we[space]take[space]in[space]the[space]present[space]implementation
#[space]is[space]the[space]requirement[space]that[space]the[space]user-given[space]plaintext[space]has[space]to[space]pass[space]the[space]check[space]of[space]the
#[space]function[space]checkplaintext(),[space]see[space]comments[space]to[space]this[space]function[space]further[space]below.

#[space]The[space]illustrative[space]examples[space]further[space]below[space]are[space]chosen[space]to[space]be[space]extremely[space]simple
#[space](thus[space]are[space]very[space]far[space]from[space]being[space]realistic)[space]yet[space]sufficiently[space]well[space]concisely
#[space]demonstrating[space]the[space]principles[space]involved.[space]In[space]practice[space]the[space]first[space](plaintext)
#[space]alphabet[space]will[space]e.g.[space]contain[space]"/"[space]or[space]"[space]"[space]and[space]at[space]least[space]a[space]scrambled[space]lower[space]case
#[space]alphabetical[space]characters.[space]WTShaw's[space]original[space]work[space]was[space]in[space]the[space]direction[space]of
#[space]Example[space]2[space]and[space]3.[space]Example[space]4[space]and[space]5[space]demonstrate[space]that[space]the[space]scheme[space]can[space]in[space]fact
#[space]easily[space]perform[space]also[space]more[space]complicated[space]processing,[space]i.e.[space]involving[space]an[space]arbitrarily
#[space]number[space]of[space]secret[space]alphabets,[space]thereby[space]enabling[space]obtaining[space]more[space]enhanced[space]security.
#[space]Particular[space]attention[space]may[space]also[space]be[space]called[space]to[space]the[space]benefits[space]of[space]post-processing[space]the
#[space]numbers[space]resulting[space]from[space]encoding,[space]as[space]we[space]indicate[space]in[space]Example[space]1.

#[space]As[space]the[space]current[space]scheme[space]is[space]for[space]substitution[space]only,[space]it[space]may[space]be[space]mentioned[space]that[space]it[space]is
#[space]generally[space]beneficial[space]and[space]desirable[space]in[space]practice[space]to[space]have[space]a[space]nice[space]mixture[space]of
#[space]confusion[space]and[space]diffusion,[space]i.e.[space]in[space]our[space]case[space]a[space]pre-[space]and/or[space]post-processing[space]with
#[space]transposition[space]schemes[space]and[space]eventually[space]also[space]in[space]combination[space]with[space]other
#[space]substitution[space]schemes[space]and[space]further[space]maybe[space]also[space]with[space]multiple[space]rounds[space]of[space]the[space]same
#[space]combination.

#[space]An[space]essential[space]advantage[space]of[space]the[space]present[space]scheme[space]is[space]apparently[space]its[space]theoretical
#[space]simplicity,[space]which[space]enables[space]most[space]common[space]users[space]to[space]fairly[space]easily[space]understand[space]and
#[space]verify[space]the[space]correctness[space]of[space]the[space]code[space]that[space]they[space]are[space]using.

#[space][1][space]http://s13.zetaboards.com/Crypto/topic/7147900/4/



#[space]The[space]user-given[space]plaintext[space]string[space]is[space]checked[space]to[space]ensure[space]that[space]it[space]doesn't[space]begin
#[space]with[space]the[space]first[space]character[space]of[space]the[space]user-given[space]plaintext[space]alphabet.[space]This[space]is[space]a
#[space]requirment[space]for[space]the[space]proper[space]functioning[space]of[space]the[space]scheme[space]but[space]is[space]in[space]practice
#[space]evidently[space]simple[space]to[space]be[space]satisfied.[space]For[space]normal[space]plaintexts[space]don't[space]begin[space]with
#[space]spaces[space]so[space]that[space]one[space]can[space]easily[space]specify[space]the[space]plaintext[space]alphabet[space]be[space]such[space]that[space]it
#[space]begins[space]with[space]the[space]space[space]character,[space]with[space]the[space]other[space]characters[space]of[space]the[space]alphabet[space]in
#[space](preferably)[space]any[space]arbitrary[space]secret[space]scrambled[space]ordering.[space](In[space]the[space]examples[space]section
#[space]we[space]choose[space]to[space]use[space]"/"[space]instead[space]of[space]"[space]"[space]to[space]represent[space]space.)[space]Note[space]that[space]the[space]other
#[space]alphabets[space]involved[space]in[space]the[space]use[space]of[space]the[space]present[space]scheme[space]are[space]not[space]required[space]to
#[space]satisfy[space]this[space]requirement,[space]see[space]the[space]examples[space]further[space]below,[space]where[space]the[space]other
#[space]alphabets[space]happen[space]to[space]even[space]to[space]contain[space]no[space]space[space]character.[space]We[space]promote[space]this
#[space]rather[space]trivial[space]checking[space]operation[space]to[space]the[space]stutus[space]of[space]a[space]function[space]in[space]order[space]to[space]call
#[space]particular[space]attention[space]of[space]the[space]users[space]to[space]the[space]constriant,[space]which,[space]if[space]violated,[space]could
#[space]lead[space]to[space]grave[space]processing[space]errors.[space]The[space]constraint[space]stems[space]from[space]the[space]fact[space]that[space]in
#[space]applying[space]the[space]fucnction[space]convtextnum()[space](the[space]first[space]of[space]such[space]calls)[space]to[space]a[space]user-given
#[space]plaintext[space]that[space]begins[space]with[space]any[space]number[space]of[space]the[space]first[space]character[space]of[space]the[space]plaintext
#[space]alphabet,[space]these[space]plaintext[space]characters[space]would[space]be[space]ignored[space]in[space]the[space]returned[space]value[space]of
#[space]convtextnum(),[space]since[space]they[space]correspond[space]to[space]the[space]"leading[space]zeros"[space]of[space]numbers,[space]cf.
#[space]the[space]formula[space]in[space]the[space]comment[space]to[space]convtextnum().[space]Later[space]invocations[space]of
#[space]convtextnum()[space]however[space]don't[space]have[space]this[space]kind[space]of[space]trouble,[space]since[space]the[space]textstr
#[space]parameter[space]of[space]them,[space]being[space]necessarily[space]the[space]result[space]of[space]a[space]previous[space]call[space]of
#[space]convnumtext(),[space]doesn't[space]have[space]characters[space]corresponding[space]to[space]"leading[space]zeros"[space]from
#[space]the[space]very[space]beginning,[space]noting[space]that[space]all[space]numbers[space]involved[space]in[space]our[space]context[space]never[space]have
#[space]"leading[space]zeros".

def[space]checkplaintext(plaintextalphabet,plaintextstr):
[space][space]assert(plaintextstr[0]!=plaintextalphabet[0])
[space][space]return
[space][space][space][space]

#[space]If[space]textstr[space]is[space]the[space]user[space]given[space]plaintext[space]it[space]is[space]assumed[space]that[space]it[space]has[space]passed[space]the
#[space]check[space]of[space]checkplaintext().
#[space]alphabet[space]denotes[space]the[space]alphabet[space]which[space]is[space]a[space]superset[space]of[space]all[space]characters[space]that[space]occur
#[space]in[space]textstr.[space]Let[space]base[space]be[space]the[space]length[space]of[space]alphabet.[space]The[space]function[space]maps[space]the
#[space]characters[space]in[space]textstr[space]to[space][0,[space]base-1][space]according[space]to[space]their[space]ordering[space]in[space]that
#[space]parameter[space](this[space]ordering[space]is[space]for[space]crypto[space]purposes[space]highly[space]preferably[space]to[space]be[space]a
#[space]secret[space]permuted[space]one)[space]and[space]converts[space]the[space]thus[space]numerically[space]encoded[space]sequence[space]with
#[space]the[space]common[space]base[space]representation[space]formula[space](I[space]=[space]a0[space]+[space]a1*B[space]+[space]a2*B^2[space]+[space].....)[space]of
#[space]integers[space]to[space]a[space]number[space](with[space]the[space]convention[space]that[space]characters[space]at[space]the[space]left[space]of[space]the
#[space]textstr[space]correspond[space]to[space]higher[space]powers[space]of[space]B).[space]If[space]textstr[space]is[space]very[space]long,[space]a[space]very
#[space]large[space]integer[space]will[space]result.[space]In[space]case[space]this[space]turns[space]out[space]to[space]be[space]undesirable,[space]the
#[space]user-given[space]plaintext[space]can[space]be[space]divided[space]into[space]a[space]number[space]of[space]appropriately[space]sized
#[space]segments[space]and[space]these[space]individually[space]processed.[space]Note[space]that[space]all[space]of[space]the[space]thus[space]obtained
#[space]segments[space]of[space]the[space]given[space]plaintext[space]must[space]pass[space]the[space]check[space]of[space]checkplaintext().

def[space]convtextnum(alphabet,textstr):
[space][space]base=len(alphabet)
[space][space]for[space]c[space]in[space]alphabet:
[space][space][space][space]assert(alphabet.count(c)==1)
[space][space]ltext=len(textstr)
[space][space]for[space]c[space]in[space]textstr:
[space][space][space][space]assert(c[space]in[space]alphabet)
[space][space]h=0
[space][space]v=base**(ltext-1)
[space][space]for[space]i[space]in[space]range(ltext):
[space][space][space][space]h+=v*(alphabet.index(textstr[i]))
[space][space][space][space]v//=base
[space][space]return(h)


#[space]Convert[space]an[space]integer[space]number[space]to[space]a[space]textstr[space]in[space]characters[space]of[space]alphabet[space]in
#[space]conformance[space]to[space]the[space]common[space]base[space]representation[space]formula.[space]In[space]case[space]alphabet[space]is[space]the
#[space]same[space]as[space]the[space]parameter[space]alphabet[space]in[space]convtextnum()[space]used[space]to[space]obtain[space]the[space]integer
#[space]parameter[space]number,[space]then[space]the[space]return[space]value[space]is[space]identical[space]to[space]the[space]textstr[space]used[space]as
#[space]the[space]parameter[space]in[space]calling[space]convtextnum(),[space]i.e.[space]in[space]this[space]special[space]case
#[space]convnumtext()[space]and[space]convtextnum()[space]are[space]reverse[space]of[space]each[space]other.

def[space]convnumtext(alphabet,number):
[space][space]base=len(alphabet)
[space][space]for[space]c[space]in[space]alphabet:
[space][space][space][space]assert(alphabet.count(c)==1)[space][space][space]
[space][space]h=number
[space][space]s=""
[space][space]while[space]h>0:
[space][space][space][space]r=h%base
[space][space][space][space]s+=alphabet[r]
[space][space][space][space]h=(h-r)//base
[space][space]sr=""
[space][space]for[space]i[space]in[space]range(len(s)-1,-1,-1):
[space][space][space][space]sr+=s[i]
[space][space]return(sr)



################################################################################



#[space]Installation[space]of[space]the[space]software.

#[space]Both[space]communication[space]partners[space]have[space]to[space]download[space]the[space]same[space]version[space]3x[space]of[space]Python
#[space]from[space]http://www.python.org.[space](Employing[space]the[space]same[space]version[space]of[space]Python[space]ensures
#[space]against[space]any[space]potentially[space]possible[space]incompatibilities[space]among[space]different[space]versions.)
#[space]The[space]present[space]code[space]can[space]be[space]stored[space]in[space]a[space]file[space]named[space]e.g.[space]numcoding.py[space]and[space]the
#[space]examples[space]given[space]below[space]run[space]in[space]Python's[space]GUI[space]IDLE.[space](File[space]-->[space]Open[space]to[space]find[space]and
#[space]open[space]the[space]file[space]then[space]in[space]the[space]window[space]showing[space]the[space]code[space]Run[space]-->[space]Run[space]Module[space]to[space]run
#[space]it.[space]One[space]could[space]also[space]type[space]numcoding.py[space]in[space]a[space]DOS-window.)[space]Modifications[space]of[space]the
#[space]code[space]in[space]the[space]code[space]window,[space]e.g.[space]the[space]plaintext[space]string,[space]can[space]be[space]done[space]online[space]and[space]the
#[space]code[space]re-run.



################################################################################



#[space]Illustrative[space]examples.

#[space]Note[space]that[space]the[space]alphabets[space]involved[space]are[space]secret[space]and[space]generally[space]in[space]well[space]scrambled
#[space]ordering[space]for[space]obtaining[space]good[space]security[space]to[space]be[space]provided[space]by[space]the[space]scheme.[space]The
#[space]user-given[space]plaintext[space]must[space]pass[space]the[space]check[space]of[space]checkplaintext().[space]For[space]convenience
#[space]of[space]illustration,[space]simplification[space]is[space]done[space]in[space]the[space]following[space]examples[space]where
#[space]feasible,[space]in[space]particular[space]the[space]alphabets[space]employed[space]are[space]evidently[space]far[space]from[space]being
#[space]well[space]scrambled[space]as[space]they[space]ideally[space]should[space]have[space]been[space]in[space]practical[space]situations.


#[space]Example[space]1.[space]Employing[space]only[space]1[space](secret)[space]alphabet,[space]the[space]obtained[space]integer[space]number[space]is
#[space]post-processed[space]by[space]a[space](secret)[space]reversible[space]transformation[space]to[space]become[space]the
#[space]ciphertext[space]for[space]transmission[space]to[space]the[space]recipient.[space]The[space]present[space]author[space]considers
#[space]this[space]post-processing[space]possibility[space]to[space]be[space]a[space]quite[space]natural[space]and[space]useful[space]one[space]to[space]be
#[space]preferably[space]exploited[space]in[space]our[space]context.[space](Being[space]demonstrated[space]once[space]here,[space]this
#[space]feasible[space]optional[space]processing[space]will[space]not[space]be[space]repeatedly[space]dealt[space]with[space]in[space]the
#[space]following[space]other[space]examples.)[space]Note[space]that[space]such[space]reversible[space]transformations[space]between
#[space]integer[space]numbers[space]abound.

print("Example[space]1:")
print()
[space][space][space][space][space][space]
alphabet="/edcbafghijklmnopqrstuvwxyz"
textstr="mary/had/a/little/lamb"

#[space]Sender[space]side:

checkplaintext(alphabet,textstr)
number=convtextnum(alphabet,textstr)
number*=3
print("ciphertext:",number)
print()

#[space]Recipient[space]side:

number//=3
textstrr=convnumtext(alphabet,number)

print("Result:",textstr,textstrr,textstr==textstrr)
print()


#[space]Example[space]2.[space]Employing[space]2[space](secret)[space]alphabets,[space]the[space]integer[space]number[space]obtained[space]with
#[space]the[space]first[space]alphabet[space]is[space]transformed[space]to[space]a[space]textstr[space]according[space]to[space]the[space]second
#[space]alphabet[space]to[space]beome[space]the[space]ciphertext[space]for[space]transmission[space]to[space]the[space]recipient.[space]The[space]second
#[space]alphabet[space]is[space]shorter[space]than[space]the[space]first.

print("Example[space]2:")
print()
[space][space][space][space][space][space]
alphabeta="/edcbafghijklmnopqrstuvwxyz"
alphabetb="fbzvsnABCD"
textstra="mary/had/a/little/lamb"

#[space]Sender[space]side:

checkplaintext(alphabeta,textstra)
numbera=convtextnum(alphabeta,textstra)
textstrb=convnumtext(alphabetb,numbera)
print("ciphertext:",textstrb)
print()

#[space]Recipient[space]side:

numberar=convtextnum(alphabetb,textstrb)
textstrar=convnumtext(alphabeta,numberar)

print("Result:",textstra,textstrar,textstra==textstrar)
print()


#[space]Example[space]3.[space]Employing[space]2[space](secret)[space]alphabets,[space]the[space]integer[space]number[space]obtained[space]with
#[space]the[space]first[space]alphabet[space]is[space]transformed[space]to[space]a[space]textstr[space]according[space]to[space]the[space]second
#[space]alphabet[space]to[space]beome[space]the[space]ciphertext[space]for[space]transmission[space]to[space]the[space]recipient.[space]The[space]second
#[space]alphabet[space]is[space]longer[space]than[space]the[space]first.[space]

print("Example[space]3:")
print()
[space][space][space][space][space][space]
alphabeta="/edcbafghijklmnopqrstuvwxyz"
alphabetb="ZYXVUrstuvwxyzabcdefghijEFGHIJKL"
textstra="mary/had/a/little/lamb"

#[space]Sender[space]side:

checkplaintext(alphabeta,textstra)
numbera=convtextnum(alphabeta,textstra)
textstrb=convnumtext(alphabetb,numbera)
print("ciphertext:",textstrb)
print()

#[space]Recipient[space]side:

numberar=convtextnum(alphabetb,textstrb)
textstrar=convnumtext(alphabeta,numberar)

print("Result:",textstra,textstrar,textstra==textstrar)
print()


#[space]Example[space]4:[space]Employing[space]3[space](secret)[space]alphabets,[space]the[space]integer[space]number[space]obtained[space]with
#[space]the[space]first[space]alphabet[space]is[space]transformed[space]to[space]a[space]textstr[space]according[space]to[space]the[space]second
#[space]alphabet[space]which[space]is[space]then[space]transformed[space]to[space]an[space]integer[space]number[space]according[space]to[space]the
#[space]third[space]alphabet[space]to[space]beome[space]the[space]ciphertext[space]for[space]transmission[space]to[space]the[space]recipient.
#[space]Note[space]that[space]in[space]this[space]case[space]alphabetc[space]has[space]to[space]contain[space]alphabetb[space]as[space]a[space]subset[space](a
#[space]proper[space]subset[space]or[space]not,[space]in[space]general[space]with[space]a[space]different[space]scrambled[space]ordering),
#[space]otherwise[space]this[space]example[space]wouldn't[space]work,[space]the[space]reason[space]being[space]that[space]in[space]convtextnum()
#[space]all[space]characters[space]in[space]textstr[space]must[space]be[space]in[space]the[space]corresponding[space]parameter[space]alphabet.[space]

print("Example[space]4:")
print()
[space][space][space][space][space][space]
alphabeta="/edcbafghijklmnopqrstuvwxyz"
alphabetb="rstuvwxyzabcdefghijEFGHIJKL"
alphabetc="EFGHIJKLZYXVUrstuvwxyzabcdefghij"
textstra="mary/had/a/little/lamb"

#[space]Sender[space]side:

checkplaintext(alphabeta,textstra)
numbera=convtextnum(alphabeta,textstra)
textstrb=convnumtext(alphabetb,numbera)
numberc=convtextnum(alphabetc,textstrb)
print("ciphertext:",numberc)
print()

#[space]Recipient[space]side:

textstrbr=convnumtext(alphabetc,numberc)
numberar=convtextnum(alphabetb,textstrbr)
textstrar=convnumtext(alphabeta,numberar)

print("Result:",textstra,textstrar,textstra==textstrar)
print()


#[space]Example[space]5:[space]Employing[space]4[space](secret)[space]alphabets,[space]the[space]integer[space]number[space]obtained[space]with
#[space]the[space]first[space]alphabet[space]is[space]transformed[space]to[space]a[space]textstr[space]according[space]to[space]the[space]second
#[space]alphabet[space]which[space]is[space]then[space]transformed[space]to[space]an[space]integer[space]number[space]according[space]to[space]the
#[space]third[space]alphabet[space]and[space]finally[space]to[space]a[space]textstr[space]according[space]to[space]the[space]fourth[space]alphabet[space]to
#[space]beome[space]the[space]ciphertext[space]for[space]transmission[space]to[space]the[space]recipient.[space]Note[space]that[space]in[space]this
#[space]case[space]alphabetc[space]has[space]to[space]contain[space]alphabetb[space]as[space]a[space]subset[space](a[space]proper[space]subset[space]or[space]not,
#[space]in[space]general[space]with[space]a[space]different[space]scrambled[space]ordering),[space]otherwise[space]this[space]example
#[space]wouldn't[space]work,[space]the[space]reason[space]being[space]that[space]in[space]convtextnum()[space]all[space]characters[space]in
#[space]textstr[space]must[space]be[space]in[space]the[space]corresponding[space]parameter[space]alphabet.[space]On[space]the[space]other[space]hand,
#[space]alphabetd[space]can[space]be[space]an[space]arbitrary[space]one,[space]though[space]we[space]have[space]chosen[space]it[space]here[space]to[space]be[space]all
#[space]lower-case[space]in[space]order[space]to[space]show[space]that[space]the[space]final[space]ciphertext[space]after[space]the[space]diverse
#[space]transformation[space]processing[space]could[space]also[space]be[space]obtained[space]in[space]the[space]given[space]plaintext
#[space]alphabet,[space]if[space]desired.

print("Example[space]5:")
print()
[space][space][space][space][space][space]
alphabeta="/edcbafghijklmnopqrstuvwxyz"
alphabetb="rstuvwxyzabcdefghijEFGHIJKL"
alphabetc="EFGHIJKLZYXVUrstuvwxyzabcdefghij"
alphabetd="uvwxyzedcbafghijklmnopqrst"
textstra="mary/had/a/little/lamb"

#[space]Sender[space]side:

checkplaintext(alphabeta,textstra)
numbera=convtextnum(alphabeta,textstra)
textstrb=convnumtext(alphabetb,numbera)
numberc=convtextnum(alphabetc,textstrb)
textstrd=convnumtext(alphabetd,numberc)
print("ciphertext:",textstrd)
print()

#[space]Recipient[space]side:

numbercr=convtextnum(alphabetd,textstrd)
textstrbr=convnumtext(alphabetc,numbercr)
numberar=convtextnum(alphabetb,textstrbr)
textstrar=convnumtext(alphabeta,numberar)

print("Result:",textstra,textstrar,textstra==textstrar)
print()

Edited by mok-kong shen, Mar 22 2014, 10:24 PM.
Offline Profile Quote Post Goto Top
 
mok-kong shen
NSA worthy
[ *  *  *  *  *  * ]
I have just posted Version 1.1 of my code at the position of OP. The title of the present thread is also changed a little bit, with the code named NUMCODING.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · General · Next Topic »
Add Reply