Thank for your suggestions, I tryed the
Base64Str() but curiosly it encode but the same instruction not decode:
EnClave64$=Base64Str("Marina", encode)
It gives us: TWFyaW5h
but is you maked the inverse EnClave64$=Base64Str("TWFyaW5h, decode)
now it gives us: VFdGeWFXNWg=
The next code is the better exmaple:
Code: Select all
;Valores por defecto de la tabla.
passwordtable={" "} ;Hay iniciarla para poder usarla, si no no graba nada.
ClaveParental$=passwordtable[0]
/****** FUNCIONES DEL MENU ******/
@MENU 0,
{
{"Crear clave parental", ID="CreaClave", Flags=#MENUITEM_TOGGLE},
{"Probar clave parental", ID="PruebaClave", Flags=#MENUITEM_TOGGLE},
}
/*****************************************************************/
Function p_MenuFunc(msg)
Switch msg.action
Case "OnMenuSelect":
Local r$=""
Local doreq=True
Switch msg.item
Case "CreaClave":
DeselectMenuItem(1, "CreaClave")
p_CreaClave()
doreq=False
Case "PruebaClave"
DeselectMenuItem(1, "PruebaClave")
p_PruebaClave()
doreq=False
Default:
r$=msg.item
EndSwitch
If doreq
If Idioma=0 ;Castellano.
If r$="" Then r$="Solicitante cancelado"
SystemRequest("", "Tú selección: " .. r$, "OK", #REQICON_INFORMATION)
ElseIf Idioma=1 ;Inglés.
If r$="" Then r$="Requester cancelled"
SystemRequest("", "Your selection: " .. r$, "OK", #REQICON_INFORMATION)
ElseIf Idioma=2 ;Italiano.
If r$="" Then r$="Operazione annullata"
SystemRequest("", "La tua selezione: " .. r$, "_OK", #REQICON_INFORMATION)
ElseIf Idioma=3 ;Francés.
If r$="" Then r$="Demandeur annulé"
SystemRequest("", "Votre sélection: " .. r$, "OK", #REQICON_INFORMATION)
EndIf
EndIf
EndSwitch
EndFunction
/**************************************************************************************************/
@DISPLAY {Title="Control parental", Width=640, Height=480, Color=#BLACK, Borderless=False, NoClose=False,
KeepProportions=True, Sizeable=False, NoModeSwitch=True}
SetDisplayAttributes({Menu=0})
/**************************************************************************************************/
Function p_Decorado()
Cls()
SetFont(#SANS, 20)
SetFontColor(#WHITE)
TextOut(#CENTER, #CENTER, "PROGRAMA PARA CREAR CLAVES DE CONTROL PARENTAL")
EndFunction
/* FUNCIONES DE TRABAJO */
Function p_CreaClave()
BeginRefresh()
Cls()
;Pedimos la clave y comprobamos que no sea en blanco.
ClaveParental1$=StringRequest("Crear clave", "Introduzca un clave alfanúmerica", "", #ALL, 0, password=False)
If ClaveParental1$=""
SystemRequest("AVISO", "No has introducido una clave", "Vale", #REQICON_ERROR)
EndIf
;Volvemos a pedir la clave para estar seguros, comprobamos que no sea en blanco y comparamos la primera con la segunda.
ClaveParental2$=StringRequest("Repetir clave", "Repita la clave instroducida", "", #ALL, 0, password=False)
If ClaveParental2$=""
SystemRequest("AVISO", "No has introducido una clave", "Vale", #REQICON_ERROR)
ElseIf ClaveParental2$<>ClaveParental1$
SystemRequest("AVISO", "No has introducido la clave correcta", "Vale", #REQICON_ERROR)
Else
;Guardamos la clave en un fichero.
EnClave64$=Base64Str(ClaveParental1$, encode)
TextOut(10, 10, "La clave es: "..ClaveParental1$)
TextOut(10, 25, "La clave es: "..EnClave64$)
ClaveParental$=ClaveParental1$
passwordtable[0]=EnClave64$
OpenFile(1, "ParentalCode.txt", #MODE_WRITE)
WriteTable(1, passwordtable)
CloseFile(1)
EndIf
EndFunction
Function p_PruebaClave()
BeginRefresh()
Cls()
;Comprobamos que exista el fichero parental.
existe=Exists("ParentalCode.txt")
If existe=False
Cls()
SetFont(#SANS, 22)
SetFontColor(#RED)
TextOut(#CENTER, #CENTER, "NO EXISTE NINGÚN FICHERO KeyCode")
Else
Cls()
OpenFile(1, "ParentalCode.txt")
Leepasswordtable=ReadTable(1)
CloseFile(1)
ClaveParental4$=Leepasswordtable[0]
DeClave64$=Base64Str(ClaveParental4$, decode)
ClaveParental$=DeClave64$
TextOut(10, 10, "La clave es: "..ClaveParental4$)
TextOut(10, 25, "La clave es: "..DeClave64$)
ClaveParental3$=StringRequest("Introducir clave", "Introduzca su clave", "", #ALL, 0, password=False)
If ClaveParental3$=""
SystemRequest("AVISO", "No has introducido una clave", "Vale", #REQICON_ERROR)
ElseIf ClaveParental$<>ClaveParental3$
SystemRequest("AVISO", "No has introducido la clave correcta", "Vale", #REQICON_ERROR)
End()
Else
Cls()
SetFont(#SANS, 22)
SetFontColor(#RED)
TextOut(#CENTER, #CENTER, "A disfrutar del juego")
EndIf
EndIf
EndFunction
p_Decorado()
InstallEventHandler({OnMenuSelect=p_MenuFunc})
EscapeQuit(True)
Repeat
WaitEvent
Forever
I'm sorry the code is in spanish and I use the menu to redo the ask parental code, I tryed with the name "Marina".