Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

comparing secure strings...

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 03-12-2008   #1 (permalink)
Ben Christian
Guest


 

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 SpecsSystem Spec
Old 03-13-2008   #2 (permalink)
Shay Levi
Guest


 

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 SpecsSystem Spec
Old 04-02-2008   #3 (permalink)
David Marvin
Guest


 

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 SpecsSystem Spec
Old 04-02-2008   #4 (permalink)
Oisin (x0n) Grehan [MVP]
Guest


 

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 ?
If you think about it a little bit more, being able to compare secure-
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 SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing two lists KeithK PowerShell 4 07-09-2008 05:27 PM
comparing hashtable values Cookiecutter PowerShell 4 05-20-2008 10:36 AM
Comparing strings - is it a bug? Tibor Soos PowerShell 7 03-13-2008 08:04 PM
Comparing filenames to strings Tim PowerShell 17 08-24-2007 10:34 AM
secure and non secure items message tim Vista security 3 07-21-2007 09:12 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51