From f46e444dae373640519ca2e311b7bd6626228706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=7E?= Date: Mon, 19 Jun 2017 10:55:29 +0800 Subject: [PATCH 1/2] Add RsaKeyType(JSON/XML) --- src/NETCore.Encrypt/Internal/RsaKeyType.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/NETCore.Encrypt/Internal/RsaKeyType.cs diff --git a/src/NETCore.Encrypt/Internal/RsaKeyType.cs b/src/NETCore.Encrypt/Internal/RsaKeyType.cs new file mode 100644 index 0000000..af0aed0 --- /dev/null +++ b/src/NETCore.Encrypt/Internal/RsaKeyType.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NETCore.Encrypt.Internal +{ + public enum RsaKeyType + { + XML, + JSON + } +} From 7702fc52c12cc9119e2030eaad32aad1059cb3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=7E?= Date: Mon, 19 Jun 2017 14:21:27 +0800 Subject: [PATCH 2/2] add base64 encrypt an decrypt --- src/NETCore.Encrypt/EncryptProvider.cs | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/NETCore.Encrypt/EncryptProvider.cs b/src/NETCore.Encrypt/EncryptProvider.cs index 69f07d6..dd7a7dc 100644 --- a/src/NETCore.Encrypt/EncryptProvider.cs +++ b/src/NETCore.Encrypt/EncryptProvider.cs @@ -617,5 +617,53 @@ private static string CreateMachineKey(int length) } #endregion + + #region Base64 + + #region Base64加密解密 + /// + /// Base64 encrypt + /// + /// input value + /// + public static string Base64Encrypt(string input) + { + return Base64Encrypt(input, Encoding.UTF8); + } + + /// + /// Base64 encrypt + /// + /// input value + /// text encoding + /// + public static string Base64Encrypt(string input, Encoding encoding) + { + return Convert.ToBase64String(encoding.GetBytes(input)); + } + + /// + /// Base64 decrypt + /// + /// input value + /// + public static string Base64Decrypt(string input) + { + return Base64Decrypt(input, Encoding.UTF8); + } + + /// + /// Base64 decrypt + /// + /// input value + /// text encoding + /// + public static string Base64Decrypt(string input, Encoding encoding) + { + return encoding.GetString(Convert.FromBase64String(input)); + } + #endregion + + #endregion } }