If you want to compress the conversion of string in SecureString to LINQ statement, you can express it as follows:
var plain = "The quick brown fox jumps over the lazy dog"; var secure = plain .ToCharArray() .Aggregate( new SecureString() , (s, c) => { s.AppendChar(c); return s; } , (s) => { s.MakeReadOnly(); return s; } );
However, keep in mind that using LINQ does not increase the security of this solution. It suffers from the same drawback as any conversion from string to SecureString . As long as the original string remains in memory, the data is vulnerable.
As stated above, the proposal proposed above is to combine the creation of SecureString , its initialization with data and, finally, blocking it from modification.
Matthias Jansen Jul 28 '15 at 8:05 2015-07-28 08:05
source share