|
Post by votan on Aug 3, 2008 10:25:02 GMT -5
I wonder if there is already a built in way to encrypt textstrings like for example passwords? RB seems to actually already support it, as the default password to log into RB is already encrypted.... (prefs.xml:<password>F56C29</password> ..... so now I wonder how we can make use of this to encrypt / decrypt passwords in our own projects..... don't like transmitting or storing passwords in plain readable text in my DB....
|
|
|
Post by mackrackit on Aug 3, 2008 11:39:48 GMT -5
I know it is not exactly what you are after, but have you looked at the "Passwordbox" command?
It works very well and passwords are stored in code space.
|
|
|
Post by votan on Aug 3, 2008 12:36:41 GMT -5
Yes, I'm aware of the passwordbox command, but this does not what I need. Guess the Server itself already supports encryption/decryption... so we just need a way to make it accessible through RB code....
|
|
|
Post by Psycho on Aug 3, 2008 15:41:42 GMT -5
Votan, The function in the following code is what I use to store passwords in a simple text file. As I think you are looking for, this prevents someone from opening the text file with notepad and being able to read the passwords. My example here uses the simple input command rather than the password box but it will convey the general idea to you. I must say that the overall idea for this was from someone who had posted on the JustBASIC sight, I believe. In my complete program, I encrypt the users password and store it in a simple text file. When they log back in with their password, I simply encrypt the variable they typed in and compare it to the encrypted version that is already saved. Hope this helps.
[start] input "Type in a password";pw1$ print print "The encrypted password is "; encrypt$(pw1$) print input "Please re-enter the password ";pw2$ print if encrypt$(pw1$) = encrypt$(pw2$) then print "Passwords match." else print "Passwords do not match." end if end
function encrypt$(pwTest$) kryptKey$="CANYOUTELLTHATTHISWORDHASBEENENCRYPTEDBECAUSEITHAS" 'Encryption key ' "Can you tell that this word has been encrypted because it has" DIM kryptArr(LEN(kryptKey$)) 'The array for ASCII value of each character for k=1 to LEN(kryptKey$) character$=MID$(kryptKey$,k,1) 'Get ASCII value of each character, one at a time val=ASC(character$) kryptArr(k)=val 'Put the value into the array next k for k=1 to LEN(pwTest$) charVal=ASC(MID$(pwTest$,k,1)) pwSave$=pwSave$+CHR$(charVal+kryptArr(k)-60) 'Save the newly encrypted character to psSave$ next k encrypt$=pwSave$ end function
Psycho
|
|
|
Post by mackrackit on Aug 3, 2008 20:46:58 GMT -5
Hey psycho,
That is cool, I can use that also.
Thanks
|
|
|
Post by votan on Aug 4, 2008 5:43:53 GMT -5
Thanx alot! Need to change some things though, to make it fit my needs.. but it's a good basis.
|
|