I have one question there is an option when you open a file in mode write for you close this file the file doesn't show the ascii charapters?
I want make a password system to saves one key for make a parents control to my erotic games, where you put one password to avoid that child... or wives play to this, but if the file with the password is ascii you can see the password, and if there is a parameter to close it without you can see this, and open the file too to use it.
CloseFile and formats to file created
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: CloseFile and formats to file created
You could use Base64Str() and then CompressFile() on that string to hide the file's content. This is of course a very weak protection but in your case it should be sufficient.
- Juan Carlos
- Posts: 889
- Joined: Mon Sep 06, 2010 1:02 pm
Re: CloseFile and formats to file created
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:
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".
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
Re: CloseFile and formats to file created
use it like this (something seems wrong to decode attribute llok reversed !!)
However you are approaching your problem wrong
in general a password for security reasons is NOT stored in any reverse form (even thought your system not really matters)
you store an NON REVERSING seed of your password and you check every time with it
i.e.
storedpasswordseed=MD5Str("Marina")
every time a user insert a password you check the checksum
if md5str(NewPassWordJustInsertedNyUSer)=passwordseed .. blah blah
Code: Select all
encoded = Base64Str("Marina",decode=True)
decoded = Base64Str(encoded,decode=False)
DebugPrint("Marina in base64 = "..encoded)
DebugPrint(encoded.." is decoded back from Base64 to "..decoded)
in general a password for security reasons is NOT stored in any reverse form (even thought your system not really matters)
you store an NON REVERSING seed of your password and you check every time with it
i.e.
storedpasswordseed=MD5Str("Marina")
every time a user insert a password you check the checksum
if md5str(NewPassWordJustInsertedNyUSer)=passwordseed .. blah blah
Christos
- Juan Carlos
- Posts: 889
- Joined: Mon Sep 06, 2010 1:02 pm
Re: CloseFile and formats to file created
Thank you for your help, I have other system as you tell me saving a code instead of name, I think that the Base64Str has the option to Code a name, I uses this wrong way because I think in the easy way and the beautiful to save the password with a name instead of numerical string.
- Juan Carlos
- Posts: 889
- Joined: Mon Sep 06, 2010 1:02 pm
Re: CloseFile and formats to file created
Thank you plouf I tested the instructions as you told me and its works fine.