Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: DrewPee on May 24, 2007
-
Hello guys - sorry it's been a while - I should be back in full flow soon - been a hectic few months since my daughter was born!
Im getting married on Monday as well so all the build up to that is near completion!
BUT Im working on something serious for work - a password generator . . .
basically all it needs to do is offset characters i.e.
"andy woz ere" becomes "bmez xpa fsf" - but you should be able to change the offset value (in this case just one!)
any ideas? in freebasic?
Drew
-
that should be quite easy drew!
the way i would do it is to create an string array that holds all the letters in the alphabet.
then something like this for offseting the password
dim as string encrypted_password(size of original password)
for x=0 to size of original password
encrypted_password(x) = alphabet_array((asc(original_password(x))-64)+offset)
next
something like that might work remeber the - 64 part is just based on if you youse big letters you should extend the array to hold big and small letters but inbetween the big and small letters put 6 spaces.
http://www.neurophys.wisc.edu/comp/docs/ascii.html
-
Thanks Nino!
The ascii table is handy too!!
Must get back into programming in FreeBasic again!!!
-
Password generator is a nice idea :)
And congratulations on your forthcoming wedding!
-
This might not be much help, but I made this a while back... just for fun. ;)
By the way, congratulations. :D
Declare Sub Encrypt_Decrypt_String( Byref Test As String, Byref Password As String )
Dim As String Test
Test = "IMPORTANT: "
Test+="READ CAREFULLY: This Microsoft End-User License Agreement (EULA) is a "
Test+="legal agreement between you (either an individual or a single entity) and "
Test+="Microsoft Corporation for the Microsoft software product identified above, "
Test+="which includes computer software and may include associated media, printed "
Test+="materials, and online or electronic documentation (SOFTWARE PRODUCT). "
Test+="By installing, copying, or otherwise using the SOFTWARE PRODUCT, you agree "
Test+="to be bound by the terms of this EULA. If you do not agree to the terms of "
Test+="this EULA, do not install or use the SOFTWARE PRODUCT; you may, however, "
Test+="return it to your place of purchase for a full refund."
Test+="Software PRODUCT LICENSE"
Test+="The SOFTWARE PRODUCT is protected by copyright laws and international "
Test+="copyright treaties, as well as other intellectual property laws and "
Test+="treaties. The SOFTWARE PRODUCT is licensed, not sold. NOTE: The terms of "
Test+="a printed, paper EULA which may accompany the SOFTWARE PRODUCT supersede "
Test+="the terms of any on-screen EULA found within the SOFTWARE PRODUCT. "
'dim as integer fnum = freefile
'open "readme.txt" for binary as #fnum
' Do while eof(fnum) = 0
' Dim As String rec
' input #fnum, rec
' Test+=rec
' loop
'close #fnum
Print Test
sleep 1000,1
cls
Dim As String Password, encrypt, decrypt
Input "Enter Password.", Password
Encrypt_Decrypt_String( Test, Password )
cls
Print Test
sleep 1000, 1
cls
Input "Enter Password.", Password
Encrypt_Decrypt_String( Test, Password )
Print Test
sleep
Sub Encrypt_Decrypt_String( Byref Test As String, Byref Password As String )
Dim As String Encrypt
Dim As Integer ti, nt, tval, plen, slen
slen = len(Test)
plen = len(password)
For i as integer = 1 to slen
tval = ASC(Mid(Test, i))
ti = (ti MOD plen) + 1
nt = ((ti+(i\plen)) MOD plen) + 1
tval XOR = (ASC(Mid(Password, ti)) * (plen + ti) + ASC(Mid(Password, nt)))
encrypt+=Chr(tVal)
Next
Test = Encrypt
End Sub
-
Have some Karma for that Dr_D.
-
never even noticed this very cool Dr_D!
-
Did I get that right, that you'd like to do something like the Caesar-Chiffre??
-
That's exactly it.
Jim
-
This is in excess of what you need, but I think its worth a mention as we are on this topic :)
The safest way to secure a password would be to use a oneway hashing algorithm like md5 or shl1
You then save the hashed password in the database, then everytime the user enters a password, it gets hashed and compared to the hashed password in the database. This has the added bonus of keeping the password hidden from system admins who have access to the database.
Because there are a lot of sites out there that store a massive database of hashed words, so you simply give it the hash and it returns the cleartext if its in the database, it would be wise to secure it further with a salt. The way this works is that each user will have an additional variable which should contain a random sequence of characters, thats associated with the username. That gets added to the end of the hashed password and send through the hashing algorithm a second time.
i.e. if I had a function called md5( String ) then each user has a record :-
Record User
Field Name : String
Field Salt : String
Field hash : String
End Record
then when I create a new User, I would also assign a random string to the Salt field.
User.Name = UserName
User.Salt = randomString( length = 6 )
Finally, when I create the hash field I would do: -
User.hash = md5( md5( Password ) + User.Salt )
where the + denotes a concatination of the hased Password and Salt.
You would use the same hashing process on the provided Password everytime the user tries to login.
This is becoming the norm for online forums/login systems too.
-
Crikey - thanks guys for all the help! Im definately back now and hopefully with some new bits n bobs soon!!!
thanks for the messages guys - appreciate it!
Drew
-
Done it . . . slightly different to what i originally thought but hey ho it works!
this is exactly what i wanted - thanks to everybody who looked on and helped!
Drew
-
heh thats kool k+