PDA

View Full Version : password script and more :)



Lionheart008
10-04-2009, 18:06
hi all:)

I have found yesterday an old password script on my notebook( I have to create it new! worked with sub function method) but it didn't fit into thinbasic language or do what I wished... eros has helped a little, so I have built this example...

may be one day thinbasic or your own little thinbasic script has to get a password to start the application or you are using a trial version... doesn't matter...

one little example with two loops :)

info: use "q" and then "f" to quit the console script! to make it faster...

more to come... I have some new ideas with this script...

my bad example looked like this:



Function Passwort() As String
Dim strPasswort As String
Dim strBuffer As String
DIM strInput as String

Printl strInput
Do
Sleep 10
strBuffer = Console_InKeyB()
If strBuffer <> "" Then
If Asc(Left$(strBuffer, 1)) = 13 Then Exit Do
If Asc(Left$(strBuffer, 1)) = 8 Then
strPasswort = Left$(strPasswort, Len(strPasswort) - 1)
Len(strPasswort) + Len(strInput) + 1
Printl (" ")
Len(strPasswort) + Len(strInput) + 1
Else
strPasswort += strBuffer
Printl ("******")
EndIf
End If
Loop
PrintL ("")
Return strPasswort
End Function


I was very near at the aim :roll:

sincerely Mr. Lionhead
...unfortunately with headache from a birthday and wine party last night... :fie:

saturday early in the mornging edit: ps: sorry, I delete the attachment for building new "password" script version complete and with some new functions so I have in mind... better to make a clear big issue than three, four little parts :) - all work in progress...

Lionheart008
28-05-2009, 20:43
=> topic: password...

hi dear thinbasic friends :)

have done a new password example and what a surprise I have one more question about this example ...

first of all here the password console script :D !!!


'-------- password try by lionheart 08.april2009
'-------- new version at 28.april2009

Uses "Console", "UI","File"

Dim InputUser, InputUser1 As String
Dim StringBuffer As String
Dim StringBuffer1 As String
dim trialPassword as string = "Lionheart"
dim lColor as long
dim Hiddenpassword as string = "Franko Lionheart"

printl
printl "-..enter your first password for LIONBASIC-Module than type ENTER.. -"
printl

'---Loop and collect entered chars till user press ENTER key
Do
sleep 10
InputUser = Console_InKeyB()
Select Case Len(InputUser)
Case 1
print "# "
StringBuffer += inputUser
Case 2
if right$(InputUser, 1) = chr$(13) then exit do
Case 3
if left$(InputUser, -1) = chr$(9) then exit do

End Select

Loop

'---Now check password and output results
printl
if StringBuffer = trialPassword then
'---Color green highlighted
lColor = Console_ForegroundRGB(0,1,0,1)
Console_SetTextAttribute(lColor)
printl
printl "Perfect! you have got the right password."
else
'---Color red highlighted
lColor = Console_ForegroundRGB(1,0,0,1)
Console_SetTextAttribute(lColor)
printl
printl " I'm sorry, password is not correct, generate new one ;) "
printl
printl " You have failed just entered: " & StringBuffer
printl " so your open Trial Password for 30 days is: " & trialpassword
printl
printl " Hidden password for LIONBASIC Module Fullversion is: " '& hiddenpassword
printl " Send now your new password by e-mail: " ' & hiddenpassword
end if

'---Color yellow highlighted
lColor = Console_ForegroundRGB(1,0,1,1)
Console_SetTextAttribute(lColor)
File_save("hidden.txt", hiddenpassword)

'---Finish
printl
printl "--- Thanks for trying LIONBASIC Module. Press any key to next task ---"
sleep 50
printl
waitkey
'------------------------

TYPE UserAccount
Username as String * 16
UserPassword as string * 16
END TYPE

dim u as UserAccount

DIM f, i, found as integer
DIM usr, usr1, pwd, yesno as string
usr = "Lionbasic"
usr1 = "Fantomas"

console_cls

printl
printl "-- do you want create a new log-in account [yes/no] ", YesNo
printl
sleep 50

'---Color yellow highlighted
lColor = Console_ForegroundRGB(1,1,0,1)
Console_SetTextAttribute(lColor)

printl "Hey, try a new log-in account with password ..."
printl
printl "-- type in something new exciting stuff :) --"
Do
sleep 10

'IF UCASE$(YN) = "Y" Then
InputUser1 = Console_InKeyB()
Select Case Len(InputUser1)
Case 1
print " * "
StringBuffer1 += inputUser1
Case 2
if right$(InputUser1, 1) = chr$(13) then exit do
Case 3
if left$(InputUser, -1) = chr$(9) then exit do
end select
sleep 10
'End if
Loop

printl
if StringBuffer1 = usr then
lColor = Console_ForegroundRGB(0,1,0,1)
Console_SetTextAttribute(lColor)
printl
printl "Great! You have got now the Second right Password."
else
lColor = Console_ForegroundRGB(1,0,0,1)
Console_SetTextAttribute(lColor)
printl
printl " I'm sorry, NEW password is not correct."
printl
printl " You have entered for NEW Account: " & StringBuffer1
printl
printl " so... you have got NEW Loginpassword for 30 days Trialperiode : " & usr
end if

printl
lColor = Console_ForegroundRGB(0,0,0,1)
Console_SetTextAttribute(lColor)
printl
printl "Great! You have got now the Second right Password."
printl "all is ok, your new account was created..."
printl
printl "... have sent your correct password by e-mail again :) "
printl

File_save("hidden2.txt", usr1)

printl "- push any key and exit script -"
waitkey

this script works nearly perfect :)

next task: I would like to interrogate such a callback with "YES / NO" callbacks.. I will see :)


printl "-- do you want create a new log-in account [yes/no] ", YesNo

servus, have all a nice day, Lionheart

Petr Schreiber
29-05-2009, 15:40
Hi Frank,

interesting script! I would recommend to support deleting characters while entering password.

To get input from user, you can pick attached custom function:

uses "Console"

dim name as string = GetInput("Enter your name: ")
printl "Your name is "+name
waitkey

function GetInput(sPrompt as string) as string

console_write sPrompt
function = console_read

end function

Petr