Tema: Encriptación por Transposición



Similar documents
// Correntista. //Conta Corrente. package Banco; public class Correntista { String nome, sobrenome; int cpf;

public class Craps extends JFrame implements ActionListener { final int WON = 0,LOST =1, CONTINUE = 2;

Schema XML_PGE.xsd. element GrupoInformes. attribute XML_PGE.xsd unqualified qualified

Using A Frame for Output

Homework/Program #5 Solutions

public class demo1swing extends JFrame implements ActionListener{

CS 335 Lecture 06 Java Programming GUI and Swing

Propiedades del esquema del Documento XML de envío:

5.17 GUI. Xiaoyi Jiang Informatik I Grundlagen der Programmierung

1. DESCRIPCIÓN DE WEB SERVICES DE INTERCAMBIO DE DATOS CON NOTARIOS

Programming with Java GUI components

Física Computacional Conceptos de programación.

Benedictine College Financial Aid

Bucle for_in. Sintaxis: Bucles for_in con listas. def assessment(grade_list): """ Computes the average of a list of grades

Apéndice C: Código Fuente del Programa DBConnection.java

Manejo Basico del Servidor de Aplicaciones WebSphere Application Server 6.0

How To Know If An Ipod Is Compatible With An Ipo Or Ipo (Sanyo)

RIGGING CONDITIONS AND PROCEDURES

INTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 7: Object-Oriented Programming. Introduction

ASP. NET. programación avanzada. Interfaz de Usuario

file://c:\dokumente und Einstellungen\Marco Favorito\Desktop\ScanCmds.html

PERSONAL INFORMATION / INFORMACIÓN GENERAL Last Name / Apellido Middle Name / Segundo Nombre Name / Nombre

Sub OPT() j = 1 k = 1 m = 1 n = 1 o = 1 g = 1 h = 1

Guia do Usuário de Criptografia de A integridade de suas informações é muito importante para nós Índice... 5

Migración y Coexistencia desde Notes a Exchange Server 2007

Dictionary (catálogo)

Apéndice C: Esquemas de la base de datos

Informatik II. // ActionListener hinzufügen btnconvert.addactionlistener(this); super.setdefaultcloseoperation(jframe.

Advanced Network Programming Lab using Java. Angelos Stavrou

Spanish GCSE Student Guide

Skills and Topics for TeenCoder: Java Programming

ECCAIRS 5 Instalación

Lösningsförslag till tentamen

TEACHER GUIDE STRATEGIES ACHIEVE READING SUCCESS. CURRICULUM ASSOCIATES, Inc. STARS SERIES E SPANISH EDITION

Estructura de aplicación en PHP para System i

DIFFERENTIATIONS OF OBJECTS IN DIFFUSE DATABASES DIFERENCIACIONES DE OBJETOS EN BASES DE DATOS DIFUSAS

To be considered for vendor space and be added to our database, please send all of the following:

Graphical User Interfaces

Quest, Inc. Title VI Complaint Procedures and Forms

Altas, Bajas y Modificaciones de Registros en tabla MYSQL

DIPLOMADO DE JAVA - OCA

Your New Denver Public Library Card

PROCEDIMIENTOPARALAGENERACIÓNDEMODELOS3DPARAMÉTRICOSA PARTIRDEMALLASOBTENIDASPORRELEVAMIENTOCONLÁSERESCÁNER

Galway Chronicle. Volume 5, Issue 10 January 9, 2015

An Inventory of My Traits

Fedora 14 & Red Hat. Descripción del curso:

OFFICE OF COMMON INTEREST COMMUNITY OMBUDSMAN CIC#: DEPARTMENT OF JUSTICE

Ranking de Universidades de Grupo of Eight (Go8)

POSIBILIDAD DE REALIZACIÓN DE PFC EN DELPHI (Luxembourg)

Unit 5. Landmarks and Large Numbers. How Much Is 1,000? Common Core

Swing. A Quick Tutorial on Programming Swing Applications

2013 ASIS PUERTO RICO CHAPTER Inc. PRESENTS: 2013 SECURITY PROGRAM DESIGN 2-Day Program

Práctica 1: PL 1a: Entorno de programación MathWorks: Simulink

The Basic Java Applet and JApplet

Update a MS

New words to remember

Summer Reading and Class Assignments Rising Seniors

Curso SQL Server 2008 for Developers

FAMILY INDEPENDENCE ADMINISTRATION Seth W. Diamond, Executive Deputy Commissioner

Reference Guide to complete an AFIP form 4550 General resolution No of the Administración Federal de Ingresos Públicos (AFIP)

GOPAL RAMALINGAM MEMORIAL ENGINEERING COLLEGE. Rajeshwari nagar, Panapakkam, Near Padappai, Chennai

Estrategias para la Reducción de Riesgos y Ciber Ataques

libro touchstone 2 workbook resuelto

This guide has information on the services, features & functions that you have with DT OneBill. ANSWER MACHINE

Señal RS232. d. codevilla v1.0

LINIO COLOMBIA. Starting-Up & Leading E-Commerce. Luca Ranaldi, CEO. Pedro Freire, VP Marketing and Business Development

UNIVERSIDAD NACIONAL AUTÓNOMA DE MÉXICO DIRECCIÓN GENERAL DE COOPERACIÓN E INTERNACIONALIZACIÓN (DGECI)

Assignment No.3. /*-- Program for addition of two numbers using C++ --*/

Extending Desktop Applications to the Web

Programa de Cursos Intensivos de Inglés (CIDI) Verano 2015

BtoB MKT Trends. El Escenario Online. Luciana Sario. Gerente de Marketing IDC Latin America 2009 IDC W W W. I D C. C O M / G M S 1

Ask your child what he or she is learning to say in Spanish at school. Encourage your child to act as if he or she is your teacher.

Monterey County Behavioral Health Policy and Procedure

Fondamenti di Java. Introduzione alla costruzione di GUI (graphic user interface)

USERS MANUAL IN.TRA.NET PROJECT

UNIVERSIDAD TÉCNICA DEL NORTE ARTÍCULO CIENTÍFICO (INGLÉS)

SUMMER WORK AP SPANISH LANGUAGE & CULTURE Bienvenidos a la clase de Español AP!

PROGRAMA DE GRAFICACIÓN DE VELOCIDADES EN VENTANAS DE MAPINFO

New words to remember

WEB SERVICES WEB SERVICES

Resumen de Entrevista: Asociación de Agentes de Aduana del Puerto de Manzanillo

New words to remember

CA Dream Application References

Quick Installation Guide. Guía de instalación rápida. Wireless 150 N USB Adapter W150NU

Multiplicative Relaxation with respect to Thompson s Metric

Prepárate. BT Computer ABCs for Women in Transition

Formato de Checklist de Auditoría a Entidad de Formación Basado en EN TPAB AUDIT. Ref. EN

Problem 1 (1.5 points)

Explorando Oportunidades Juntos Juntos

Cliente de correo electronico en modo texto: mutt. Por Paco Aldarias Raya. Impreso: 19 de enero de 2006

HEALTH QUESTIONNAIRE (QUESTIONARIO DE SALUD)

Curso académico 2015/2016 INFORMACIÓN GENERAL ESTRUCTURA Y CONTENIDOS HABILIDADES: INGLÉS

l McConnell Public Safety and Transportation Operations Center

Avocados Australia, PO Box 8005 Woolloongabba Queensland 4102 Australia

How To Build A Swing Program In Java.Java.Netbeans.Netcode.Com (For Windows) (For Linux) (Java) (Javax) (Windows) (Powerpoint) (Netbeans) (Sun) (

BALANCE DUE 10/25/2007 $ STATEMENT DATE BALANCE DUE $ PLEASE DETACH AND RETURN TOP PORTION WITH YOUR PAYMENT

Entry to Year 7 - Information for Parents

SUBCHAPTER A. AUTOMOBILE INSURANCE DIVISION 3. MISCELLANEOUS INTERPRETATIONS 28 TAC 5.204

Técnicas Avanzadas de Inteligencia Artificial Dpt. Lenguajes y Sistemas Informáticos. FISS. UPV-EHU

New Server Installation. Revisión: 13/10/2014

Transcription:

import java.awt.*; import java.awt.event.*; import javax.swing.*; public class PrincipalSO extends JApplet implements ActionListener { // Declaración global JLabel lblclave, lblencriptar, lblencriptado, lbltitulo,lblencriptado2,lblencriptado3; JTextField txtclave; JButton btnprocesar,btncancela, btndesencrypta,btnenvia,btnlimpia; JTextArea txtencriptar, txtencriptado,txtencriptado2,txtencriptado3; JScrollPane scpscroll1, scpscroll2,scpscroll22,scpscroll23; int x=0; int FILAS=0,COLUMNAS=0; private char n[][]; String o[][]; int cantex = 0; String original=""; String mensaenrip=""; String claveencriptada=""; // Crea la interfaz gráfica de usuario: GUI public void init() { setlayout(null); setsize(640,480); setbackground(color.lightgray); lbltitulo = new JLabel("Algoritmo de Transposición por Sustitución",JLabel.CENTER); lbltitulo.setbackground(new Color(226,223,234)); lbltitulo.setforeground(color.black); lbltitulo.setopaque(true); lbltitulo.setfont(new Font("dialog",3,23)); lbltitulo.setbounds(0,10,640,30); add(lbltitulo); lblencriptar = new JLabel("Texto a Encriptar:"); lblencriptar.setbounds(10,100,100,30); add(lblencriptar); txtencriptar = new JTextArea(); txtencriptar.setfont(new Font("Arial",Font.BOLD,13)); scpscroll1 = new JScrollPane(txtEncriptar); scpscroll1.setbounds(120,100,180,80); add(scpscroll1); Curso: Sistema Operativo Page 1 of 7

lblclave = new JLabel("Clave :"); lblclave.setbounds(10,50,100,20); add(lblclave); txtclave = new JTextField(); txtclave.setfont(new Font("Arial",Font.BOLD,13)); txtclave.setbounds(120,50,180,30); add(txtclave); btnprocesar = new JButton("Encrypta"); btnprocesar.setbounds(120,190,90,30); btnprocesar.addactionlistener(this); add(btnprocesar); btnlimpia = new JButton("Limpiar"); btnlimpia.setbounds(380,410,90,30); btnlimpia.addactionlistener(this); add(btnlimpia); btncancela = new JButton("Cancelar"); btncancela.setbounds(210,190,90,30); btncancela.addactionlistener(this); add(btncancela); lblencriptado = new JLabel("Texto Encriptado:"); lblencriptado.setbounds(400,40,100,30); add(lblencriptado); txtencriptado = new JTextArea(); txtencriptado.setfont(new Font("Arial",Font.BOLD,13)); txtencriptado.seteditable(false); txtencriptado.setbackground(color.lightgray); txtencriptado.setforeground(color.blue); scpscroll2 = new JScrollPane(txtEncriptado); scpscroll2.setbounds(380,80,200,100); add(scpscroll2); btnenvia = new JButton("Enviar"); btnenvia.setbounds(400,190,90,30); btnenvia.setvisible(false); btnenvia.addactionlistener(this); add(btnenvia); lblencriptado2 = new JLabel("Texto Recibido"); lblencriptado2.setbounds(130,270,100,30); add(lblencriptado2); txtencriptado2 = new JTextArea(); txtencriptado2.setfont(new Font("Arial",Font.BOLD,13)); Curso: Sistema Operativo Page 2 of 7

txtencriptado2.seteditable(false); txtencriptado2.setbackground(color.lightgray); txtencriptado2.setforeground(color.blue); scpscroll22 = new JScrollPane(txtEncriptado2); scpscroll22.setbounds(100,300,200,100); add(scpscroll22); btndesencrypta = new JButton("Desencrypta"); btndesencrypta.setbounds(100,410,120,30); btndesencrypta.addactionlistener(this); btndesencrypta.setvisible(false); add(btndesencrypta); lblencriptado3 = new JLabel("Mensaje Decifrado"); lblencriptado3.setbounds(390,270,120,30); add(lblencriptado3); txtencriptado3 = new JTextArea(); txtencriptado3.setfont(new Font("Arial",Font.BOLD,13)); txtencriptado3.seteditable(false); txtencriptado3.setbackground(color.lightgray); txtencriptado3.setforeground(color.blue); scpscroll23 = new JScrollPane(txtEncriptado3); scpscroll23.setbounds(380,300,200,100); add(scpscroll23); // Procesa eventos de tipo ActionEvent public void actionperformed(actionevent e) { if (e.getsource() == btnprocesar) procesar(); if (e.getsource() == btndesencrypta) desencryta(); if (e.getsource() == btncancela) borrar(); if (e.getsource() == btnenvia) envia(); if (e.getsource() == btnlimpia) limpiatodo(); void envia(){ imprimir("mensaje Enviado..."); btnenvia.setvisible(false); Curso: Sistema Operativo Page 3 of 7

imprimir2(mensaenrip); btndesencrypta.setvisible(true); void procesar(){ x=0; n = new char[0][0]; String clave = txtclave.gettext(); original=clave; String texto = txtencriptar.gettext(); if(!clave.equals("") &&!texto.equals("")){ cantex = texto.length(); COLUMNAS = clave.length(); FILAS = (cantex/( clave.length())+1); if(cantex % COLUMNAS!= 0) FILAS = FILAS + 1; if(filas==1){ FILAS=FILAS+1; o = new String[FILAS][COLUMNAS]; n = new char[filas][columnas]; llenar(texto,filas,columnas,n); // listar(filas,columnas,n); ordenarenascenso(); btnenvia.setvisible(true); else imprimir("ingrese mensaje"); void borrar(){ txtclave.settext(""); txtencriptado.settext(""); txtencriptar.settext(""); void desencryta(){ /*txtclave.settext(""); txtencriptado.settext(""); txtencriptar.settext("");*/ desencriptar(original); btndesencrypta.setvisible(false); Curso: Sistema Operativo Page 4 of 7

void limpiatodo(){ txtclave.settext(""); txtencriptado.settext(""); txtencriptar.settext(""); txtencriptado2.settext(""); txtencriptado3.settext(""); void llenar(string t,int f, int c, char[][] n){ for (int i=0; i<f;i++) for (int j=0; j<c; j++){ if (i==0){ // en esta parte ingresal arreglo la clave para que valla como cabezara for (int r=0; r<c; r++) n[i][r] = txtclave.gettext().charat(r); i++; if(x<cantex) //el if es para que cuando llege al final de la cadena llene con n[i][j] = t.charat(x); //espacios en blanco los registros del arreglo que faltan else n[i][j] =' '; //ese era el error x = x+1; public void listar(int f, int c,char[][] a) { for (int i=0; i<f; i++) { for (int j=0; j<c; j++) txtencriptado.append("n[" + i + "][" + j + "] : " +a[i][j] + "\t"); txtencriptado.append("\n"); imprimir(""); private void imprimir(string s) { txtencriptado.append(s + "\n"); private void imprimir2(string s) { txtencriptado2.append(s + "\n"); Curso: Sistema Operativo Page 5 of 7

private void imprimir3(string s) { txtencriptado3.append(s + "\n"); void ordenarenascenso() { String aux[][]; String q[][]; q = new String[FILAS][COLUMNAS];//temporal para comparar cada casilla datos en string nos faciluta usar numeros y letras aux = new String[FILAS][COLUMNAS];// para guarda datos antes de mover for (int a=0; a<columnas; a++) //lleno el arreglo q que es string con datos n para comparar for(int b=0; b<filas; b++) q[b][a]=n[b][a]+""; for (int i=0;i<columnas-1; i++) { for (int j=i+1; j<columnas; j++){ if (q[0][i].compareto(q[0][j]) > 0) { for(int m=0;m<filas;m++){ aux[m][i] = q[m][i]; q[m][i] = q[m][j]; q[m][j] = aux[m][i]; String mensaje=""; String cla=""; String letra=""; for (int a=0; a<columnas; a++) //lleno el arreglo q que es string con datos n para comparar for(int b=1; b<filas; b++){ letra=q[b][a]; // if(!letra.equals(' ')) mensaje=mensaje+letra; mensaenrip=mensaje; // lista(filas,columnas,q); imprimir(mensaje); o=q; //para sacar la clave for (int a=0; a<columnas; a++) letra=q[0][a]; cla=cla+letra; claveencriptada=cla; Curso: Sistema Operativo Page 6 of 7

public void lista(int f, int c,string[][] a) { for (int i=0; i<f; i++) { for (int j=0; j<c; j++) txtencriptado.append("n[" + i + "][" + j + "] : " +a[i][j] + "\t"); txtencriptado.append("\n"); imprimir(""); void desencriptar(string orig){ char u=' '; String u2=""; String p[][]; p= new String[FILAS][COLUMNAS]; for (int a=0; a<columnas; a++) { u=orig.charat(a); u2=u+""; for(int v=0;v<columnas; v++){ if(o[0][v].equals(u2)){ for(int n=0;n<filas; n++) p[n][a]=o[n][v]; //lista(filas,columnas,p); String mensaje=""; String letra=""; for(int b=1; b<filas; b++) for (int a=0; a<columnas; a++){ letra=p[b][a]; //if(!letra.equals(' ')) mensaje=mensaje+letra; imprimir3 ("Clave :"+orig); imprimir3 ("texto :"+mensaje); // Curso: Sistema Operativo Page 7 of 7