![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | comparing secure strings... i want to compare 2 user inputted secure strings $strA = read-host -assecurestring "Enter String" $strB = read-host -assecurestring "Re-Enter String" if ($strA -eq $strB) { write-host "Strings Match" } else { write-host "Strings do NOT match" } but...the problem is that it seems to always return false =( any suggestions? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: comparing secure strings... You can convert the secure strings to plain text and do the comparison: $strA = read-host -assecurestring "Enter String" $strB = read-host -assecurestring "Re-Enter String" $tmpA = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($strA)) $tmpB = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($strB)) $tmpA -eq $tmpB ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > i want to compare 2 user inputted secure strings > > $strA = read-host -assecurestring "Enter String" > $strB = read-host -assecurestring "Re-Enter String" > if ($strA -eq $strB) { write-host "Strings Match" } else { write-host > "Strings do NOT match" } > > but...the problem is that it seems to always return false =( > > any suggestions? > |
My System Specs![]() |
| | #3 (permalink) |
| | RE: comparing secure strings... I have the same question. I don't want to convert the SecureString back into text as this defeats the purpose of the SecureString. Can this be accomplished without using ConvertFrom-SecureString ? |
My System Specs![]() |
| | #4 (permalink) |
| | Re: comparing secure strings... On Apr 2, 4:04*pm, David Marvin <DavidMar...@xxxxxx> wrote: Quote: > I have the same question. *I don't want to convert the SecureString backinto > text as this defeats the purpose of the SecureString. *Can this be > accomplished without using ConvertFrom-SecureString ? strings without decrypting them also defeats the purpose ;-) function crack-password ($secureString) { $words = get-content dictionary.txt foreach ($word in $words) { $crypted = ConvertTo-SecureString $word if ($crypted -eq $secureString) { write-host "Password is $word" break; } } } Of course, this imaginary function will NOT work. Hope this clears things up, :-) - Oisin PowerShell MVP http://www.nivot.org/ |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Trouble comparing strings | PowerShell | |||
| Comparing dates with If | PowerShell | |||
| Comparing strings - is it a bug? | PowerShell | |||
| Comparing filenames to strings | PowerShell | |||
| secure and non secure items message | Vista security | |||