diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations/Security/EncryptionManager.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Security/EncryptionManager.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/MediaBrowser.Server.Implementations/Security/EncryptionManager.cs b/MediaBrowser.Server.Implementations/Security/EncryptionManager.cs new file mode 100644 index 000000000..73a4e3004 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Security/EncryptionManager.cs @@ -0,0 +1,36 @@ +using MediaBrowser.Controller.Security; +using System; +using System.Security.Cryptography; +using System.Text; + +namespace MediaBrowser.Server.Implementations.Security +{ + public class EncryptionManager : IEncryptionManager + { + /// <summary> + /// Encrypts the string. + /// </summary> + /// <param name="value">The value.</param> + /// <returns>System.String.</returns> + /// <exception cref="System.ArgumentNullException">value</exception> + public string EncryptString(string value) + { + if (value == null) throw new ArgumentNullException("value"); + + return Encoding.Default.GetString(ProtectedData.Protect(Encoding.Default.GetBytes(value), null, DataProtectionScope.LocalMachine)); + } + + /// <summary> + /// Decrypts the string. + /// </summary> + /// <param name="value">The value.</param> + /// <returns>System.String.</returns> + /// <exception cref="System.ArgumentNullException">value</exception> + public string DecryptString(string value) + { + if (value == null) throw new ArgumentNullException("value"); + + return Encoding.Default.GetString(ProtectedData.Unprotect(Encoding.Default.GetBytes(value), null, DataProtectionScope.LocalMachine)); + } + } +} |
