Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
stats
Starting Member
10 Posts |
Posted - 2006-02-04 : 10:22:52
|
| After searching on the internet, I've not had any luck. Can anyone suggest anything.This is what I currently hav (without any encryption processes):ALTER PROCEDURE registerUser @userName char(16), @userPass char(16), @fullName char(10), @addr1 char(15), @addr2 char(15), @city char(10), @postcode char(8), @tel char(4), @email char(30)AS-- Make sure username does'nt already existIF EXISTS (SELECT * FROM userTable WHERE userName = @userName) RETURN -1ELSEBEGIN--Insert new row into user tableINSERT INTO userTable (userName, userPass, fullName, addr1, addr2, city, postcode, tel, email)VALUES (@userName, @userPass, @fullName, @addr1, @addr2, @city, @postcode, @tel, @email)RETURN 1ENDALTER PROCEDURE userLogin @userName char(16), @userPass char(16)AS-- Make sure username and password is correctIF EXISTS (SELECT userID, userName, userPass FROM userTable WHERE userName = @userName AND userPass = @userPass) BEGIN SELECT userID, userName, userPass FROM userTable WHERE userName = @userName AND userPass = @userPass RETURN 1 ENDGOSTaTs |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-02-04 : 10:28:08
|
| How secure do you want it to be?==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
stats
Starting Member
10 Posts |
Posted - 2006-02-04 : 10:54:12
|
| a simple encryption is all I need here and now.STaTs |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-02-04 : 11:15:21
|
| Then ALTER PROCEDURE registerUser@userName char(16),@userPass char(16),@fullName char(10),@addr1 char(15),@addr2 char(15),@city char(10),@postcode char(8),@tel char(4),@email char(30)ASdeclare @encryptpwd varchar(1000)select @encryptpwd = reverse(@userPass)--Insert new row into user tableINSERT INTO userTable (userName, userPass, fullName, addr1, addr2, city, postcode, tel, email)select @userName, @encryptpwd, @fullName, @addr1, @addr2, @city, @postcode, @tel, @emailwhere not exists (select * from userTable where userName = @userNameif @@rowcount <> 1RETURN -1elseRETURN 1ENDALTER PROCEDURE userLogin@userName char(16),@userPass char(16)ASdeclare @encryptpwd varchar(1000)declare @userid intselect @encryptpwd = reverse(@userPass)-- Make sure username and password is correctSELECT @userID = userIDFROM userTableWHERE userName = @userName AND userPass = @encryptpwdif @userID is not nullbeginselect userid = @userid RETURN 1endGOI've just used reverse here.It's important to keep the encryption separate from the rest of the code as it may change.Also never decrypt what is in the table to check the password. You may go to an encryption where that's not possible.Another easy encryption is xor'ing the bits which will give you something that is at least unreadable.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-02-04 : 11:36:22
|
| Play around with something like thisdeclare @encryptpwd varchar(1000)declare @i intselect @encryptpwd = @userPassselect @i = 0while @i < len(@userpwd)beginselect @i = @i + 1select @encryptpwd = stuff(@encryptpwd, @i, 1, char(ascii(substring(@userpwd, @i, 1))^100))end==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
stats
Starting Member
10 Posts |
Posted - 2006-02-04 : 12:16:34
|
| thanks. what does the "stuff" method do?STaTs |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-02-04 : 12:18:31
|
| stuff deletes and inserts characters in a string. In this case it just deletes one char ind inserts another at the same place - in effect replacing it.Have a look in bol.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|
|