Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to store a system.net.mail password in the database
    text
    copied!<p>I need to store email passwords which will be used with system.net.mail. These need to be retrieved and sent as plain text but I don't want to store them as plain text. This isn't really about security as its for an intranet and I just don't want the results being displayed in plain text in the CMS.</p> <p>I've read plenty of articles saying that storing password should be done using SHA1. From what I've read hashing is no good because the plain text cant be retrieved. </p> <p>I am currently trying this methods:</p> <pre><code>public static string EncodePasswordToBase64(string password) { try { byte[] encData_byte = new byte[password.Length]; encData_byte = System.Text.Encoding.UTF8.GetBytes(password); string encodedData = Convert.ToBase64String(encData_byte); return encodedData; } catch (Exception ex) { throw new Exception("Error in base64Encode" + ex.Message); } } </code></pre> <p>and</p> <pre><code>public static string DecodeFrom64(string encodedData) { System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding(); System.Text.Decoder utf8Decode = encoder.GetDecoder(); byte[] todecode_byte = Convert.FromBase64String(encodedData); int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); char[] decoded_char = new char[charCount]; utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0); string result = new String(decoded_char); return result; } </code></pre> <p>but I cant seem to find the correct data type in my database to store the value. Its currently set to <em>nvarchar(MAX).</em> </p> <p>The cell contents display like this (with spaces between each value):</p> <blockquote> <p>Q X B j L W V w M X B =</p> </blockquote> <p>Strangely when I click and enter the cell to copy the data all I get is:</p> <blockquote> <p>Q</p> </blockquote> <p>What data type should I use for this column?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload