Ejemplo n.º 1
0
 /// <summary>
 /// Decrypt object with a given password
 /// </summary>
 /// <param name="encryptedObjectString">Encrypted object (in Base64 format) that was encrypted with one of the Encode (or compatible) methods</param>
 /// <param name="password">Plain text password that was used to encrypt the text</param>
 /// <typeparam name="T">Type of object into which to serialize result</typeparam>
 /// <returns>Deserialized object</returns>
 public static T Decode<T>(string encryptedObjectString, string password) where T : class
 {
     var key = makeKey(password);
     byte[] encryptedBytes = CryptoUtils.ToBytes(encryptedObjectString, _defaultStringFormat);
     byte[] plainBytes = Decode(encryptedBytes, password);
     return Serialize.From.Binary<T>(plainBytes);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Decrypt text with a given password
 /// </summary>
 /// <param name="encryptedText">Encrypted text in Base64 format that was encrypted with one of the Encode (or compatible) methods</param>
 /// <param name="password">Password that was used to encrypt the text</param>
 /// <returns>Plain text</returns>
 public static string Decode(string encryptedText, string password)
 {
     var key = makeKey(password);
     byte[] encryptedBytes = CryptoUtils.ToBytes(encryptedText, _defaultStringFormat);
     byte[] plainBytes = Decode(encryptedBytes, password);
     return CryptoUtils.FromBytes(plainBytes, StringFormat.Unicode);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Encrypt text with a given password.  Returns string in Base64 format.  (Internally use RijindaelManaged encryptor)
 /// </summary>
 /// <param name="plainText">Text that will be encrypted</param>
 /// <param name="password">Password will be used to encrypt the text</param>
 /// <returns>Encrypted text in Base64 format</returns>
 public static string Encode(string plainText, string password)
 {
     byte[] plainBytes     = CryptoUtils.ToBytes(plainText, StringFormat.Unicode);
     byte[] encryptedBytes = Encode(plainBytes, password);
     return(CryptoUtils.FromBytes(encryptedBytes, _defaultStringFormat));
 }