Como crear una matrix cubica para encriptar palabras paso a paso
Pues deves redactar un documento en python de la siguiente manera, o simplemente copias y lo pegas en un editor de texto y lo guardas de la siguiente manera matriz.py
print ('hello everyone this is a program for to lock sentence in one matrix cubic.')
print ('Each letter has one number that you chose for each letter. if you want to exit type exit in the bush')
print ('Now you have to enter the tree file of matrix, for one matrix such as this:')
print ('[a,b,c')
print (' d,e,f')
print (' g,h,i]')
a = input ('enter the value of the a ')
b = input ('enter the value of the b ')
c = input ('enter the value of the c ')
d = input ('enter the value of the d ')
e = input ('enter the value of the e ')
f = input ('enter the value of the f ')
g = input ('enter the value of the g ')
h = input ('enter the value of the h ')
i = input ('enter the value of the i ')
file = [float(a),float(d),float(g)]
file2 = [float(b),float(e),float(h)]
file3 = [float(c),float(f),float(i)]
m = [file,file2,file3]
diag = [m[i][i] for i in [0,1,2]]
diag2 = [file[1],file2[2],file3[0]]
diag3 = [file[2],file2[0],file3[1]]
diagrl = [file3[0],file2[1],file[2]]
diagrl2 = [file3[1],file2[2],file[0]]
diagrl3 = [file3[2],file2[0],file[1]]
col1 = [row[0] for row in m]
col2 = [row[1] for row in m]
col3 = [row[2] for row in m]
det2 = diag[0]*diag[1]*diag[2]+diag2[0]*diag2[1]*diag2[2]+diag3[0]*diag3[1]*diag3[2]-diagrl[0]*diagrl[1]*diagrl[2]-diagrl2[0]*diagrl2[1]*diagrl2[2]-diagrl3[0]*diagrl3[1]*diagrl3[2]
det = 1/det2
f = [(file2[1]*file3[2]-file3[1]*file[2])*det,(-1*(file[1]*file3[2]-file3[1]*file[2]))*det,(file[1]*file2[2]-file2[1]*file[2])*det]
f2 = [(-1*(file2[0]*file3[2]-file3[0]*file2[2]))*det,(file[0]*file3[2]-file3[0]*file[2])*det,(-1*(file[0]*file2[2]-file2[0]*file[2]))*det]
f3 = [(file2[0]*file3[1]-file3[0]*file2[1])*det,(-1*(file[0]*file3[1]-file3[0]*file[1]))*det,(file[0]*file2[1]-file2[1]*file[1])*det]
mt = [f,f2,f3]
def unlock():
j = input ('enter the value of j ')
k = input ('enter the value of k ')
l = input ('enter the value of l ')
file4 = [float(j),float(k),float(l)]
file4xm = [file4[0]*f[0]+file4[0]*f[1]+file4[0]*f[2],file4[1]*f2[0]+file4[1]*f2[1]+file4[1]*f2[2],file4[2]*f3[0]+file4[1]*f3[1]+file4[2]*f3[2]]
print (file4xm)
def lock():
j = input ('enter the value of j ')
k = input ('enter the value of k ')
l = input ('enter the value of l ')
file4 = [float(j),float(k),float(l)]
file4xm = [file4[0]*file[0]+file4[0]*file[1]+file4[0]*file[2],file4[1]*file2[0]+file4[1]*file2[1]+file4[1]*file2[2],file4[2]*file3[0]+file4[1]*file3[1]+file4[2]*file3[2]]
print (file4xm)
print ('If you want to exit the program you should to type the next comman exit in the bush when the program asks you that enter a comman.')
print ('The comman are lock (for to lock letter), unlock (for to unlock letter), matrixinv (for to show the matrix inverse), det (for to show the determinant)')
print ('Now if you still to want follow locking the letters, you should to enter the matrix 3x1, such as.')
print ('[j,k,l]')
while True:
comman = input ('enter a comman ')
if comman == 'exit':
break
elif comman == 'lock':
lock()
elif comman == 'unlock':
unlock()
elif comman == 'matrixinv':
print (mt)
elif comman == 'det':
print (det)
Una vez haya relizado este documento de python simplemente lo abren y en criptan palabras con esta matriz cubica
Asi como la matriz cuadrada que esplique en mi aterior blog
