Encrypt a Password using Certificate

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).

[Reflection.Assembly]::LoadWithPartialName(“System.Security”)
$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)))
[Convert]::ToBase64String($env.Encode())

Execute this and you will get the encrypted password..

Let us know your ratings on this blog here. Also feel free to contact me here.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s