vb net code snippets for storing password
The solution for “vb net code snippets for storing password” can be found here. The following code will assist you in solving the problem.
///
/// Encrypts a given password and returns the encrypted data
/// as a base64 string.
///
/// An unencrypted string that needs
/// to be secured.
/// A base64 encoded string that represents the encrypted
/// binary data.
///
/// This solution is not really secure as we are
/// keeping strings in memory. If runtime protection is essential,
/// should be used.
/// If
/// is a null reference.
public string Encrypt(string plainText)
{
if (plainText == null) throw new ArgumentNullException(“plainText”);
//encrypt data
var data = Encoding.Unicode.GetBytes(plainText);
byte[] encrypted = ProtectedData.Protect(data, null, Scope);
//return as base64 string
return Convert.ToBase64String(encrypted);
}
///
/// Decrypts a given string.
///
/// A base64 encoded string that was created
/// through the or
/// extension methods.
/// The decrypted string.
/// Keep in mind that the decrypted string remains in memory
/// and makes your application vulnerable per se. If runtime protection
/// is essential, should be used.
/// If
/// is a null reference.
public string Decrypt(string cipher)
{
if (cipher == null) throw new ArgumentNullException(“cipher”);
//parse base64 string
byte[] data = Convert.FromBase64String(cipher);
//decrypt data
byte[] decrypted = ProtectedData.Unprotect(data, null, Scope);
return Encoding.Unicode.GetString(decrypted);
}
More questions on [categories-list]
- tss from gene granges
- ixl ansers ixl ansers
- get coin prices node-binance
- how to setup netflix workflow worker
- spritesheets in pyqt spritesheets in pyqt
- cahokia mounds pictures cahokia mounds pictures cahokia mounds pictures
- python 2 decimal places how to get decimal part of a double in python set number of decimals python
- how to find nuber of tweets per day using python how to find nuber of tweets per day using python how to find nuber of tweets per day using python how to find nuber of tweets per day using python how to find nuber of tweets per day using python
- haskell get specific elements of a String
- vb net code snippets for storing password
- error TS2307: Cannot find module ‘@ngx-meta/core’.
- inline scripts encapsulated in tags