Encrypting password using a certificate is a simple process that would take just few minutes. You can do this in two ways. Check below to see how it can be done?
1. You can make use of CSEncrypt tool for this. For this you need to download Windows Azure Command line. Or else if you’ve downloaded but not sure where it is installed just browse to “C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\version\bin\” and you can find csencrypt.exe there. 🙂
Now open a command prompt, and move to the location specified above. Now use the following command to encrypt the password:
csencrypt encrypt-password -CopyToClipboard -Thumbprint “<your certificate thumbprint>”
and enter the password when prompted. And that’s it!! 🙂
2. Another alternative is to make use of Powershell (Preferably ISE). Please note that using this method needs the certificate to be imported in you local machine (or wherever this command is executing).
$pass = [Text.Encoding]::UTF8.GetBytes(“Your Password“)
$content = new-object Security.Cryptography.Pkcs.ContentInfo –argumentList (,$pass)
$env = new-object Security.Cryptography.Pkcs.EnvelopedCms $content
$env.Encrypt((new-object System.Security.Cryptography.Pkcs.CmsRecipient(gi cert:\CurrentUser\My\Your Certificate Thumbprint)))
Execute this and you will get the encrypted password..