Encryption (General)

  • Hi There,

    What would the best way be to encrypt a password within a script?

    Its to do with replication. We have to drop and re-create a publication with many articles on a farily regular basis. To recreate this publicaton, we have a script, but the password for the service account has to be stored in the script too.

    The script is to be used in Dev, Staging and Live, so has to be portable.

    We want to encrypt the password so we can store the script safley away from prying eyes.

    Any suggestions on a way to achieve this?

    Many Thanks.

  • An example of the sort of code that I would like:

    exec [Database].sys.sp_addlogreader_agent

    @job_login = 'Replication_Service_Account'

    ,@job_password = DECRYPT('Encrypted Password goes here') --Pseudo code here..

    ,@publisher_security_mode = 1

    ,@job_name = null

  • There shouldn't be a reason to store the password in the stored procedure.

    you might need to dynamically generate SQL and use exec() or sp_executesql, but you should be able to keep it out. That would be for the best.

    Apart from that if you call your script from another script, store the password in an encrypted column and decrypt it when you need to retrieve it.

    ~BOT

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

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