Get substring from a password

Hi,

I’ve a scenario in which I retrieve a password from an asset. Now I want first four characters of it how to achieve this?

Hi @Babjee_Vangipurapu

FinalPassword = YourPassword.Substring(0, 4)

Regards,

@Babjee_Vangipurapu

Password = "Abcdefgh@1234567"
FinalPassword = Password.Substring(0, 4)

Regards,

Hi @lrtetala ,

My password is a secure string not a normal string. Will the substring work the same way on password?

@Babjee_Vangipurapu

Then try this

str_Password = New System.Net.NetworkCredential(String.Empty,Password).Password
FinalPassword = str_Password.Substring(0, 4)

Regards,

(New System.Net.NetworkCredential(String.Empty,Password).Password).Substring(0, 4)

@Babjee_Vangipurapu

Follow these steps.

  1. Use Get Credential activity. This will return you output String User Id and SecureString password
  2. Use Assign activity to convert SecureString to String like this
    stringPasswordVariable== new System.Net.NetworkCredential(string.Empty, secureStringVariable).Password
  3. Now get the first four charachters using Assign Activity like this
    stringFirstFourChar = stringPasswordVariable.Substring(0, 4)

Thanks,
Ashok :slight_smile: