Encrypt text in PSeInt

0

The program has to encrypt a phrase that the user enters via the keyboard. For example: If you enter Hello as a phrase and 8 as a key, the program should return Encrypted: IIIH

The problem is that no result is shown on the screen.

SubProceso tado <- ascii ( Frase, clave)
    Definir CodLet, g Como Cadenas;
    CodLet <- "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    Definir i, j, k, L Como Enteros;
    clave <- 0;
    Frase <- "";
    k <-0;
    Definir tado Como Cadena;
    tado <- "";
    Para i<-1 Hasta longitud(Frase) Con Paso 1 Hacer
        g<-SubCadena(Frase, i, i);
        Para j<-1 Hasta 26 Con Paso 1 Hacer
            Si g=SubCadena(Codlet, j, j) Entonces
                k<-j;
            FinSi
        FinPara
        L<-(k+clave) % 27;
        tado <-concatenar(tado,subcadena(CodLet, L, L));
    FinPara
FinSubProceso

Proceso sin_titulo
    Definir Frase Como Cadena;
    Definir clave Como Entero;
    Leer Frase;
    Leer Clave;
    Escribir ascii(Frase,Clave);
FinProceso
    
asked by Alejandro Caro 23.09.2018 в 16:03
source

1 answer

0

It's been a while since I saw PSeInt haha

First, you have an error here:

clave <- 0;
Frase <- "";

You are canceling the values you pass by calling the function from the process, making it never enter the Para.

And ... I do not think that if you enter "Hello" it will return "IIIH" since the comparisons are made on CodLet that only has capital letters, so at most, when entering "Hello" only, by how I see what is done, I would repeat the encryption value for 'H' 4 times. You should include lowercase letters in another CodLet or at least make it compare 'g' with uppercase and lowercase letters.

The part that marked you as an error would have to delete it from the code, because it does not let you do any of the other.

Greetings!

    
answered by 23.09.2018 / 21:27
source