# How to convert a String to Security String Using Visual Basic

**URL:** <https://forum.uipath.com/t/how-to-convert-a-string-to-security-string-using-visual-basic/28145>\
**Category:** Help\
**Tags:** system, activities\
**Created:** [April 5, 2018, 10:57pm UTC](https://forum.uipath.com/t/how-to-convert-a-string-to-security-string-using-visual-basic/28145 "2018-04-05T22:57:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonga2018](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@Jonga2018](https://forum.uipath.com/u/Jonga2018)\
**Post date:** [April 5, 2018, 10:57pm UTC](https://forum.uipath.com/t/how-to-convert-a-string-to-security-string-using-visual-basic/28145/1 "2018-04-05T22:57:30Z")

</div>

HI guys, I need to convert a String to Security String Using Visual Basic. Some Ideas???  
Best Rewards

---

<div class="post-metadata">

**Author:** ![lainh](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/lainh/32/218589_2.png) [@lainh](https://forum.uipath.com/u/lainh)\
**Post date:** [April 6, 2018, 1:28am UTC](https://forum.uipath.com/t/how-to-convert-a-string-to-security-string-using-visual-basic/28145/2 "2018-04-06T01:28:50Z")

</div>

Hi @Jonga2018

You can use “Invoke code” activity to coding like that below:

* * *

```
Dim chars As String = [_your target string_]
Dim teststring As System.Security.SecureString = _
    New System.Security.SecureString()

For Each ch As Char In chars
    teststring.AppendChar(ch)
Next
[_output securestring_]=teststring.Copy  

```

* * *

just a sample ,maybe can work with you.

---

<div class="post-metadata">

**Author:** ![Silviu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/silviu/32/11321_2.png) [@Silviu](https://forum.uipath.com/u/Silviu)\
**Post date:** [April 6, 2018, 3:31am UTC](https://forum.uipath.com/t/how-to-convert-a-string-to-security-string-using-visual-basic/28145/3 "2018-04-06T03:31:30Z")

</div>

Another way is with the NetworkCredential type:

> (new System.Net.NetworkCredential(“”, “myString”)).SecurePassword

![image](https://global.discourse-cdn.com/uipath/original/3X/9/6/9639f7232e6582b5ba8868b82bd99e4bd32c9b33.png)

And to convert from SecureString to String, you can use:

> (new System.Net.NetworkCredential(“”, mySecureString,)).Password

---

<div class="post-metadata">

**Author:** ![Jonga2018](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@Jonga2018](https://forum.uipath.com/u/Jonga2018)\
**Post date:** [April 6, 2018, 2:59pm UTC](https://forum.uipath.com/t/how-to-convert-a-string-to-security-string-using-visual-basic/28145/4 "2018-04-06T14:59:02Z")

</div>

thanks guys for the answers the both of the answers solve my problem.  
Best Rewards.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [October 29, 2018, 9:20am UTC](https://forum.uipath.com/t/how-to-convert-a-string-to-security-string-using-visual-basic/28145/5 "2018-10-29T09:20:52Z")

</div>

Closed on October 29, 2018, 9:20am UTC


