Password Encryption

  • Hai

    For Password encryption i used PWDEncrypt ()and PWDCompare() in Sql Server 7.0 But it is not working in Sql Server 2000. PWDCompare() always returns FALSE

    Table Name : SecUsers

    Encrypted value field :

    USPassword nVarchar(10)

    This is the code

    SELECT @Valid = PWDCompare(@PWD, (Select(USPassword )

    From SecUsers

    Where USCode = @USCode))

    SELECT @Valid = ISNULL(@Valid,0)

    Regards

  • Try this

    Create table users

    ( Userid int,

    Pwd VARBINARY(32) )

    INSERT INTO users VALUES (3,CONVERT(VARBINARY(32),PWDENCRYPT('TTT')))

    Select * from users

    Declare @Valid int

    SELECT @Valid = PWDCOMPARE('TTT', Pwd) FROM users where Userid = 3

    Select @Valid = Isnull (@Valid,0)

    Print @Valid

    -- Returns 1

    SELECT @Valid = PWDCOMPARE('TTT', Pwd) FROM users where Userid = 2

    Select @Valid = Isnull (@Valid,0)

    Print @Valid

    -- Returns 0

    Shas3

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply