securestring

How can I use powershell's read-host function to accept a password for an external service?

扶醉桌前 提交于 2019-11-29 11:00:37
问题 I have a script I'm writing that makes a connection to a SOAP service. After the connection is made, I need to pass in a the username/pass with every command I send. The problem I have is that when I use read-host to do this, my password is shown in cleartext and remains in the shell: PS C:\Users\Egr> Read-Host "Enter Pass" Enter Pass: MyPassword MyPassword If I hide it with -AsSecureString, the value can no longer be passed to the service because it is now a System.Security.SecureString

Is it possible to safely get a SecureString value from VB .NET?

橙三吉。 提交于 2019-11-29 07:27:33
I've always felt like SecureString was a little odd, but assumed most of my issues with it were due to security problems I don't understand. Today I decided to sit down and teach myself about it, but I've hit what seems like a fatal snag. The scenario I envision is "user enters password into text box, that password is hashed and compared to a stored hash". At first I was worried that the text box contained the string, but then I realized you could roll a custom text box that uses SecureString as its store. Cool. It's the "that password is hashed and compared..." part that is giving me trouble.

SecureString to Byte[] C#

做~自己de王妃 提交于 2019-11-29 04:23:44
How would I get a byte[] equivalent of a SecureString (which I get from a PasswordBox )? My objective is to write these bytes using a CryptoStream to a file, and the Write method of that class takes a byte[] input, so I want to convert the SecureString to the byte[] so I can use in with a CryptoStream . EDIT: I don't want to use string as it defeats the point of having a SecureString I modified from the original answer to handle unicode IntPtr unmanagedBytes = Marshal.SecureStringToGlobalAllocUnicode(password); byte[] bValue = null; try { byte* byteArray = (byte*)unmanagedBytes.GetPointer(); /

Using SecureString

送分小仙女□ 提交于 2019-11-28 18:26:22
问题 Can this be simplified to a one liner? Feel free to completely rewrite it as long as secureString gets initialized properly. SecureString secureString = new SecureString (); foreach (char c in "fizzbuzz".ToCharArray()) { secureString.AppendChar (c); } 回答1: You could use Linq: "fizzbuzz".ToCharArray().ToList().ForEach(p => secureString.AppendChar(p)); 回答2: Just use NetworkCredential. It has the conversion logic built-in. SecureString ss = new NetworkCredential("", "fizzbuzz").SecurePassword;

Convert String to SecureString

懵懂的女人 提交于 2019-11-28 16:36:18
How to convert String to SecureString ? You don't. The whole reason for using the SecureString object is to avoid creating a string object (which is loaded into memory and kept there in plaintext until garbage collection). However, you can add characters to a SecureString by appending them. var s = new SecureString(); s.AppendChar('d'); s.AppendChar('u'); s.AppendChar('m'); s.AppendChar('b'); s.AppendChar('p'); s.AppendChar('a'); s.AppendChar('s'); s.AppendChar('s'); s.AppendChar('w'); s.AppendChar('d'); There is also another way to convert between SecureString and String . 1. String to

How is SecureString “encrypted” and still usable?

爱⌒轻易说出口 提交于 2019-11-28 06:13:29
According to MSDN SecureString contents is encrypted for additional safety so that if the program is swapped to disk the string contents can't be sniffed. How is such encryption possible I wonder? The algorithm would be fixed and therefore either well-known or deductible (say one of seven widely used in industry algorithms) and there must be a key somewhere in the program. So the attacker could fetch the encrypted string, fetch the key and decrypt the data. How can such encryption be useful? NetSquirrel I'm quoting from an article about the DPAPI which is used to derive the key. This should

Is it possible to safely get a SecureString value from VB .NET?

扶醉桌前 提交于 2019-11-28 01:17:02
问题 I've always felt like SecureString was a little odd, but assumed most of my issues with it were due to security problems I don't understand. Today I decided to sit down and teach myself about it, but I've hit what seems like a fatal snag. The scenario I envision is "user enters password into text box, that password is hashed and compared to a stored hash". At first I was worried that the text box contained the string, but then I realized you could roll a custom text box that uses SecureString

Is there any benefit to using SecureString in ASP.NET?

浪子不回头ぞ 提交于 2019-11-27 17:58:23
If I understand correctly, this is for keeping plain text out of memory, so that the app is secure against esoteric attacks on memory, the garbage heap, or memory paged to disk. The SecureString is fed unmanaged bytes and consumed one unmanaged byte at at time--then the string is erased from memory. (Correct me if I way off!) In ASP.NET, the secret is collected in a webform, which post back in HTTPS. But then the Request object turns all the request values from the form into name value pairs and puts them in a collection, e.g. Request["TxtPassword"]-- so even before I can get the string, it's

Convert a secure string to plain text

别等时光非礼了梦想. 提交于 2019-11-27 11:01:09
I'm working in PowerShell and I have code that successfully converts a user entered password into plain text: $SecurePassword = Read-Host -AsSecureString "Enter password" | convertfrom-securestring | out-file C:\Users\tmarsh\Documents\securePassword.txt I've been tried several ways to convert it back, but none of them seem to work properly. Most recently, I've tried with the following: $PlainPassword = Get-Content C:\Users\tmarsh\Documents\securePassword.txt #convert the SecureString object to plain text using PtrToString and SecureStringToBSTR $BSTR = [System.Runtime.InteropServices.Marshal]:

Convert String to SecureString

冷暖自知 提交于 2019-11-27 09:42:39
问题 How to convert String to SecureString ? 回答1: You don't. The whole reason for using the SecureString object is to avoid creating a string object (which is loaded into memory and kept there in plaintext until garbage collection). However, you can add characters to a SecureString by appending them. var s = new SecureString(); s.AppendChar('d'); s.AppendChar('u'); s.AppendChar('m'); s.AppendChar('b'); s.AppendChar('p'); s.AppendChar('a'); s.AppendChar('s'); s.AppendChar('s'); s.AppendChar('w'); s