Re: Encrpted value to store in a variable

  • Hi all,

    I have a stored procedure to encrypt a value then I want that encrpted value to store in a table.  In my stored procedure I call extended stored procedure to encrypt passed in parameter how do I get this encrpted value to store in a variable?

    CREATE proc sp_TestNum

    @Number1 varchar(180)

    as

    exec master..xp_repl_encrypt @Number1 output

    insert into tblPassword

    --values  ('IT', '@encrptedvalue')

    --need Help w/ @encrptedvalue'

    Thanks much!

  • Declare @evalue varchar(?)

    SELECT @evalue = master..xp_repl_encrypt @number1 output

    INSERT tblpassword (column name 1, column 2)

    values ('IT', @evalue)

    ****

    I know it is optional, but I always list the columns to be inserted.

    This should work.

    Quand on parle du loup, on en voit la queue

  • PBirch, Thanks for your replied.

    I was able to get the previous post working but I am having trouble comparing the encrypted values. The stored procedure I have makes sense but I can't  the encrypted values match up .  Could you take a look?  Thanks!!

    CREATE proc sp_CheckPassword_bak

    @initials char(3),

    @passwd varchar(180)

    as

    declare @hashwd varchar(180)

    exec  master..xp_repl_encrypt @passwd output

    select @hashwd = passwd from tblPassword where initials = 'abc'

    if @@rowcount > 0

    begin

     if @hashwd = @passwd

     return(0)

     else

     return(1)

    end

    else

    return (100)

    go

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

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