Vbscript Encrypt Decrypt Password
If the VBS file contains sensitive information, such as passwords, use the Windows Encrypting File System, which is built into Windows operating systems, to encrypt the file and protect it from unauthorized use.
Walkthrough: Encrypting and Decrypting Strings in Visual Basic. 3 minutes to read.In this articleThis walkthrough shows you how to use the class to encrypt and decrypt strings using the cryptographic service provider (CSP) version of the Triple Data Encryption Standard algorithm. The first step is to create a simple wrapper class that encapsulates the 3DES algorithm and stores the encrypted data as a base-64 encoded string. Then, that wrapper is used to securely store private user data in a publicly accessible text file.You can use encryption to protect user secrets (for example, passwords) and to make credentials unreadable by unauthorized users. This can protect an authorized user's identity from being stolen, which protects the user's assets and provides non-repudiation. Encryption can also protect a user's data from being accessed by unauthorized users.For more information, see. ImportantThe Rijndael (now referred to as Advanced Encryption Standard AES) and Triple Data Encryption Standard (3DES) algorithms provide greater security than DES because they are more computationally intensive.
For more information, see. To create the encryption wrapper.Create the Simple3Des class to encapsulate the encryption and decryption methods. Public NotInheritable Class Simple3DesEnd Class.Add an import of the cryptography namespace to the start of the file that contains the Simple3Des class.
Imports System.Security.Cryptography.In the Simple3Des class, add a private field to store the 3DES cryptographic service provider. Private TripleDes As New TripleDESCryptoServiceProvider.Add a private method that creates a byte array of a specified length from the hash of the specified key.
Private Function TruncateHash(ByVal key As String,ByVal length As Integer) As ByteDim sha1 As New SHA1CryptoServiceProvider' Hash the key.Dim keyBytes As Byte =System.Text.Encoding.Unicode.GetBytes(key)Dim hash As Byte = sha1.ComputeHash(keyBytes)' Truncate or pad the hash.ReDim Preserve hash(length - 1)Return hashEnd Function.Add a constructor to initialize the 3DES cryptographic service provider.The key parameter controls the EncryptData and DecryptData methods. Sub New(ByVal key As String)' Initialize the crypto provider.TripleDes.Key = TruncateHash(key, TripleDes.KeySize 8)TripleDes.IV = TruncateHash(', TripleDes.BlockSize 8)End Sub.Add a public method that encrypts a string.

How To Protect Vbs File With Password
In most of the scenarios, we require password to login into the application or database or in any tool.It is good practice not to expose the password in the script or data input. To achieve that, we can encrypt the password and use that encrypted password as input.We will see how to encrypt and decrypt the password.Password Encryption: Password can be encrypted in 2 ways in UFT.1. Using the UFT in-built utility2.
Vbs Xor Encryption

Using Encrypt methodUFT in-built encryption tool: To access this go to the path – “C:Program Files (x86)HPUnified Functional TestingbinCryptonApp.exe”Write your password in ‘Password box’ and click on Generate.You will get a encoded string i.e. Encoded password.That can be used to in place of actual password.SetSecure method is used to set the encoded password as shown below. We are logging into the UFT sample application ‘Flight GUI’.