Encriptador y Desencriptador en Ensamblador

download Encriptador y Desencriptador en Ensamblador

of 19

Transcript of Encriptador y Desencriptador en Ensamblador

HIGHER EDUCATION TECHNOLOGY TIANGUISTENCODIVISION OF COMPUTER SYSTEMS ENGINEERING

Title:Encryption of text files in assemblyStudentEduardo Gonzalez OrtizGroup3602

Approach Privacy in the handling of files containing information of importance to some people today has become a necessity to maintaining that inaccessible information to third parties that could give misuse, for that reason people have the ability to using tools developed techniques called "Techniques encryption" which are processes to become unreadable information with the application of mathematical algorithms designed by a programmer, this algorithm is applied inversely to information for later decryption. Target Create an algorithm using assembly language (assembler 8086) for encrypting distinct files (. Text files, images, etc.) with no larger than 1 Mb because the process will be slow and take a few minutes inclusive hours, the algorithm requested 5 characters (numeric or only letters) to the user to carry out the encryption of data, such data will be appended to the beginning of the file to perform the decryption. Justification Give the user a tool that allows you to keep important information inaccessible to persons considered unsuitable, giving the user the ability to have a custom encryption key (to apply the 5 characters), which is a great advantage since only tool user know the data that have been employed for encryption and giving a greater degree of security which is almost impossible to know another.

1.1 What is encrypted?This is a security measure that is used for storing or transferring sensitive information that should not be accessible to third parties. They can be passwords, nos. credit card, private conversations, etc.. To encrypt information and complex mathematical formulas are used to decrypt, use as a key parameter for these formulas. The plaintext is called encryption or encryption cipher. (Alegsa, s.f.)1.2 What is Assembler?The term assembler (assembler English) refers to a type of computer program that is responsible for translating a source file written in assembler language, an object file containing machine code directly executable by the microprocessor. (Wikipedia, s.f.)Types of assemblers Basic Assemblers. They are very low, and their task is basically to provide symbolic names to the different instructions, parameters and such things as modes. Modular 32-bit or high-level assemblers. Assemblers are appeared in response to a new architecture for 32-bit processors, many of them having backward compatibility with programs can work with 16-bit structures. In addition to performing the same task as the previous ones, also allowing the use of macros, allow use structures typical of high-level languages more complex programming.

1.3 Tools Emu8086EMU8086 - MICROPROCESSOR EMULATOR is a Shareware software in Development category developed by emu8086 (Intel 8086).Free DFD 1.1Free DFD 1.1 is a program for creating flowcharts, that can be used to graphically represent a wide range of algorithms, run and debug if errors are found. (BlogSpot, 2013)1.4 DiagrammingFig. 1.1

Development2.1 Code

inicio:MOV AH,06MOV BH,1Fh ;FONDO AZUL TEXTO BLANCO MOV CX,0000 ;INICIO REN,COLMOV DX,6080 ;FIN REN,COLINT 10Hmov bx,00h ;encriptar /desencriptarmenu:mov dx,0205hmov ah,02hmov bh,00hint 10h mov dx,offset opcmov ah,09h int 21hmov ah,01hint 21h

cmp al,'1'je encriptarcmp al,'2'je desencriptarMOV AH,06MOV BH,1Fh ;FONDO AZUL TEXTO BLANCO MOV CX,0000 ;INICIO REN,COLMOV DX,6080 ;FIN REN,COLINT 10Hjmp menuencriptar:mov dx,offset datosmov ah,09h int 21h;solicitud de caracteres leerCaracteres:mov ah,01hint 21h;compara con enter para salir de la solicitud de cmp al,0dhje archivo

add bl,al;and bl,0fh inc contcmp cont,05hje archivojmp leerCaracteresarchivo: mov si,00h;mensaje para busqueda del archivomov dx,offset msjnom mov ah,09h int 21h;inicializacion del segemento de datos;Abrir archivo por nombre desde tecladoleer2:mov ax,0000mov ah,01hint 21h cmp al,0dhje abrirArchivo mov tituloArchivo[di],alinc di loop leer2abrirArchivo: mov dl,bl mov opr,bl mov al, 0 ;modo de accesopara abrir arhivo, modolectura/escritura mov dx, offset tituloArchivo ;offset lugar de memoria donde esta lavariable mov ah, 3dh ;se intenta abrir el archivo int 21h jc error ; si se prendio la bandera c ir a error mov handle, ax ;si no paso mover a lo que le dio el SO jmp leer error: ;leer archivo leer: mov bx, handle mov cx, 1 mov dx, offset leido mov ah, 3fh int 21h cmp ax, 0 ;ax queda en 0 cuando llega a EOF jz FIN ;si es 0 entonces va a fin para cerrar archivo mov dl,leido[0] add dl,opr ;mueve a vec los datos leidos del archivo mov vec[si],dl inc si ;mov ah,02h ;int 21h jmp leer FIN: ;cerramos archivo ;mov bx, handle mov ah, 3eh int 21h ;ret ;crear nuevo archivomov dx,offset msjnom2 mov ah,09h int 21h mov di,00hleerTituloArchivoACrear:mov ax,0000mov ah,01hint 21hcmp al,0dhje crearArchivoE mov vtext[di],alinc di jmp leerTituloArchivoACrearcrearArchivoE: mov ah,3Chmov cx,00hmov dx,offset vtextint 21hjc salir ;si no se pudo crearmov dx,offset msjcreado ;nombre del mensajemov ah,09 ; mov ah,09 sirve para presentar el msj en pantallaint 21h ;interrupcion de video mov bx,axmov ah,3eh ;cierra el archivoint 21h;abrir el archivo apenas creado editar:;abrirmov ah,3dhmov al,1hmov dx,offset vtextint 21hjc salir ;Si hubo error;Escritura de archivomov bx,ax ; mover hadfilemov cx,si ;num de caracteres a grabarmov dx,offset vecmov ah,40hint 21h mov dx,offset msjcreado2 ;nombre del mensaje mov ah,09 ; mov ah,09 sirve para presentar el msj en pantalla int 21h ;interrupcion de video cmp cx,axjne salir ;error salirmov ah,3eh ;Cierre de archivoint 21hdesencriptar:mov dx,offset datosmov ah,09h int 21h

;solicitud de caracteres leerCaracteresD:mov ah,01hint 21h;compara con enter para salir de la solicitud de cmp al,0dhje archivoDadd bl,al;and bl,0fh inc contcmp cont,05hje archivoDjmp leerCaracteresDarchivoD: mov si,00h;mensaje para busqueda del archivomov dx,offset msjnom3 mov ah,09h int 21h;inicializacion del segemento de datos;Abrir archivo por nombre desde teclado

leer2D:mov ax,0000mov ah,01hint 21hcmp al,0dhje abrirArchivoD mov tituloArchivo[di],alinc di loop leer2DabrirArchivoD: mov dl,blmov opr,blmov al, 0 ;modo de accesopara abrir arhivo, modolectura/escrituramov dx, offset tituloArchivo ;offset lugar de memoria donde esta lavariablemov ah, 3dh ;se intenta abrir el archivoint 21hjc errorD ; si se prendio la bandera c ir a errormov handle, ax ;si no paso mover a lo que le dio el SOjmp leerD errorD: ;leer archivo leerD: mov bx, handle mov cx, 1 mov dx, offset leido mov ah, 3fh int 21h cmp ax, 0 ;ax queda en 0 cuando llega a EOF jz FIND ;si es 0 entonces va a fin para cerrar archivo mov dl,leido[0] sub dl,opr ;mueve a vec los datos leidos del archivo mov vec[si],dl inc si ;mov ah,02h ;int 21h jmp leerD FIND: ;cerramos archivo ;mov bx, handle mov ah, 3eh int 21h ;ret

;crear nuevo archivomov dx,offset msjnom2 mov ah,09h int 21h mov di,00hleerTituloArchivoACrearD:mov ax,0000mov ah,01hint 21hcmp al,0dhje crearArchivoD mov vtext[di],alinc di jmp leerTituloArchivoACrearDcrearArchivoD: mov ah,3Chmov cx,00hmov dx,offset vtextint 21hjc salir ;si no se pudo crear mov dx,offset msjcreado ;nombre del mensaje mov ah,09 ; mov ah,09 sirve para presentar el msj en pantalla int 21h ;interrupcion de video mov bx,axmov ah,3eh ;cierra el archivoint 21h

;abrir el archivo apenas creado editarD:;abrirmov ah,3dhmov al,1hmov dx,offset vtextint 21hjc salir ;Si hubo error;Escritura de archivomov bx,ax ; mover hadfilemov cx,si ;num de caracteres a grabarmov dx,offset vecmov ah,40hint 21h mov dx,offset msjcreado3 ;nombre del mensaje mov ah,09 ; mov ah,09 sirve para presentar el msj en pantalla int 21h ;interrupcion de video

cmp cx,axjne salir ;error salirmov ah,3eh ;Cierre de archivoint 21hsalir: mov ah,04chint 21h leido db "$"handle dw ? ;identificadordel arhivoaux db "$"cont db 0 datos db 13,10,"Ingresa los valores para encriptar el archivo: $",13,10opr db ? vtext db 100 dup('',0) tituloArchivo db 100 dup('',0) opc db 13,10,"1.-Encriptar 2.-Desencriptar $",13,10msjnom db 0ah,0dh, 'Nombre del archivo a encriptar: ', '$'msjnom3 db 0ah,0dh, 'Nombre del archivo a desencriptar: ', '$'msjnom2 db 0ah,0dh, 'Nombre del nuevo archivo: ', '$'msjcreado db 0ah,0dh, 'Archivo creado con exito', '$'msjcreado2 db 0ah,0dh, 'Archivo encriptado con exito', '$' msjcreado3 db 0ah,0dh, 'Archivo desencriptado con exito', '$'

vec db 50 dup('')

2.2 Results1.-The file to encrypt is in C:\emu8086\MyBuild (Fig. 2.1) with name 1.txt

Fig. 2.1

2.-When we run the program in emu8086we see the window how show the picture 2.2.First we going to select the number one.

Fig. 2.23.-The program request the values for encrypt the file, we need provide between one to five values for continues with the encrypt, after provide the values we going to provide the file name to encrypt (Fig. 2.3).

Fig. 2.34.-Provide the file name and we key press enter to continue (Fig. 2.4), while the program encrypt the file we wait a few minutes depend the size file until the program sho the message Nombre del nuevo archivo(Fig. 2.5)

Fig. 2.4

Fig. 2.55.-Provide the new File name(Fig.2.6), and key press enter to continue.The program finished when we see the messages Archivo creado con exito and Archivo encriptado con exito(Fig. 2.7)Fig. 2.6Fig. 2.7

6.-We going to check in C:\emu8086\MyBuild to see our new encrypted file, and we see the new file how that show in the picture (Fig. 2.8).

Fig. 2.8

7.-To Decrypt the file is the same process the only change is when the program request a selection we going to key press 2 (Fig. 2.9).Fig. 2.9

Results of decrypt process (Fig. 2.10, Fig. 2.11):Fig. 2.10

Fig. 2.11

ConclusionsThe program can encrypt and decrypt any file but it is take a few minutes inclusive hours depend the file size but the results was the planned. The only disadvantage is that the user need know exactly the password to decrypt the file.

Bibliographies:Alegsa. (s.f.). Alegsa. Recuperado el 18 de 07 de 2014, de http://www.alegsa.com.ar/Dic/encriptacion.phpBeekman, G. (2005). Introduccion a la informatica. Madrid: Pearson Educacion, S.A.BlogSpot. (01 de 2013). BlogSpot. Recuperado el 18 de 07 de 2014, de http://diagramas-de-flujo.blogspot.mx/2013/01/programa-realizar-diagramas-flujo.htmlelectronicautil, B. (08 de 2008). Electronica util. Recuperado el 18 de 07 de 2014, de http://electronicautil.blogspot.mx/2008/08/emu8086-v-405.htmlhttp://es.wikipedia.org/wiki/Ensamblador

Bookmarks The Intel 8086 and Intel 8088 (i8086, officially called iAPX 86, and i8088) are two 16-bit microprocessors designed by Intel in 1978, initiators of the x86 architecture. The difference between the i8086 and i8088 is that the latter uses an 8-bit external bus, circuits used to support less expensive microprocessor, as opposed to 16-bit bus i8086. " (electronicautil, 2008)

ScheduleNo.ActivityDate

JuneJuly

272829301234567891011

1Createtitle

2Target

3Justification

4Approach

5Search the topic and understand the topic

6Create DFD

7Codification and test

8Resultevaluation

9Createteoricalframework

10Project presentation