How to encrypt and decrypt

Hii
In a notepad file we have username=abc; password=abc
but I want passoword to be encrypted.
ui path must fetch this password and encrypt it and ten decrypt and enter into the website login credentials

1 Like

@KarthikBallary

  1. use Read Text file to read Text from notepad file and store it in a string variable.

  2. Then apply String manipulation functions or regular expression to fetch password from that String.

  3. check below thread to convert String to secure string and then pass it to Type Secure text Activity to type password.

SecureString.xaml (6.1 KB)

not working kindly check it nd tell

@KarthikBallary

It will read password from split text file and encrypt it and then will write into split1 text file. Please find the attached file for your reference.

Encrypt password.zip (2.0 KB)

1 Like

thanks, can we edit in the same file

1 Like

username=abc
password=123a
isencrypted=false

if this is the content in notepad.
make it true once it is encrypted

if(isencrypted=“false”)…this condition not working, always taking to else condition

System.Text.RegularExpressions.Regex.Match(read,"(?<=(isencrypted=)).*").Value

by the way where you are using this “key” -->“passwordEncryptKey”
where it is used?

1 Like

@KarthikBallary

use Decrtypt Text activity and pass this key to decrypt the encrypted text.

@KarthikBallary

After reading the text from text file and you are storing it in a string variable.

Then check below in IF condition

IF textOutput.Contains(“false”) then do encrypt text.

textOutput.replace("false’,“true”) - To replace false with true.

Thanks,
now it is encrypting
now not updating in the same file

1 Like

@KarthikBallary

Have you used this method to replace the text. After this, again you have to write this output into text file by using Write Text activity. Then only it will update.

ya I did,
false to true is replaced but not encrypted pwd

password.xaml (9.8 KB)

@KarthikBallary

Please share your workflow with me.

I have uploaded the file check it

@KarthikBallary

Here, you used Write Text activity two times.
image

First time it wrote encrypted text and then again you are updating status. That time it will override the previous content.

To overcome this issue, use Append Line activity instead of Write Text activity.

if I use append I am getting like this

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.