Matriz cuadrada en python
Hola a todos amigos hoy les voy a enseñar a encriptar palabras en pyhton.
pues simplemente copien el codigo y luego coloque una amtriz cuadrada dentro del programa de python
print ('hello everyone this is program of the one matrix square')
print ('You have enter the number for the matrix square.')
print ('for example [a,b')
print (' c,d]')
a = input ('enter the number for the letter a ')
b = input ('enter the number for the letter b ')
c = input ('enter the number for the letter c ')
d = input ('enter the number for the letter d ')
file = [float(a),float(c)]
file2 = [float(b),float(d)]
m = [file,file2]
col = [row[0] for row in m]
col2 = [row[1] for row in m]
diag = [m[i][i] for i in [0,1]]
diagrl = [file2[0],file[1]]
det2 = diag[0]*diag[1]-diagrl[0]*diagrl[1]
det = 1/det2
f = [file[0]*det,(-1*file2[0])*det]
f2 = [(-1*file[1])*det,file2[1]*det]
mt = [f,f2]
def lock():
e = input ('enter the number for the letter e ')
g = input ('enter the number for the letter g ')
f3 = [float(e),float(g)]
f3l = [file[0]*f3[0]+file[1]*f3[0],file2[0]*f3[1]+file2[1]*f3[1]]
print (f3l)
def unlock():
e = input ('enter the number for the letter e ')
g = input ('enter the number for the letter g ')
f3 = [float(e),float(g)]
f3l = [f[0]*f3[0]+f[1]*f3[0],f2[0]*f3[1]+f2[1]*f3[1]]
print (f3l)
print ('Theses is the comman: for to lock you have to enter l, for to unlock you have to enter ul, for to exit you have to type q')
print ('For to see the matrix inverse you have to type mt, for to see the determinant you have to type det.')
print ('Remember that you have enter the file such as this example,')
print ('[e')
print (' g]')
while True:
comman = input ('enter a comman ')
if comman == 'q':
break
elif comman == 'l':
lock()
elif comman == 'ul':
unlock()
elif comman == 'det':
print (det2)
elif comman == 'mt':
print (mt)
Ahora bien puedes colocar la siguiente matriz
Incritar la siguiente oración (I love you)
Donde cada letra tiene el siguiente valor a = 1 para b = 2 así hasta llegar a z = 25, claro esta para el alfabeto ingles punto es 26 y espacio es 0
Su cripta quedaría así (45, 0, 60, 75, 110, 25, 0, 120, 120, 105)
Ahora intentelo usted
No hay comentarios.:
Publicar un comentario