shakun
11 months ago
20 changed files with 446 additions and 118 deletions
-
1Business/Business.csproj
-
74Business/Mobile/MobileServices.cs
-
9Business/MobileV2/IMobileV2Business.cs
-
28Business/MobileV2/MobileV2Business.cs
-
19Business/SendMoney/SendMoneyBusiness.cs
-
64Business/Utility/AesOperation.cs
-
2Common/APIJsonResponse.cs
-
9Common/Model/JsonRxResponse.cs
-
3Common/Model/TPSendMoney/TpSendMoney.cs
-
5Common/Model/TranHistoryResponse.cs
-
2Common/Model/TransactionResponse.cs
-
23Common/Model/WalletStatementResponse.cs
-
1JsonRx/Api/CustomerController.cs
-
33JsonRx/ApiV3/MobileV3Controller.cs
-
17JsonRx/AuthFilter/TokenAuthenticationAttribute.cs
-
7JsonRx/Helper/Util.cs
-
4JsonRx/Web.config
-
117Repository/Mobile/MobileServicesRepo.cs
-
2Repository/MobileV2/IMobileV2Repo.cs
-
144Repository/MobileV2/MobileV2Repo.cs
@ -0,0 +1,64 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Security.Cryptography; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Business.Utility |
|||
{ |
|||
public static class AesOperation |
|||
{ |
|||
public static string EncryptString(string key, string plainText) |
|||
{ |
|||
byte[] iv = new byte[16]; |
|||
byte[] array; |
|||
|
|||
using (Aes aes = Aes.Create()) |
|||
{ |
|||
aes.Key = Encoding.UTF8.GetBytes(key); |
|||
aes.IV = iv; |
|||
|
|||
ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV); |
|||
|
|||
using (MemoryStream memoryStream = new MemoryStream()) |
|||
{ |
|||
using (CryptoStream cryptoStream = new CryptoStream((Stream)memoryStream, encryptor, CryptoStreamMode.Write)) |
|||
{ |
|||
using (StreamWriter streamWriter = new StreamWriter((Stream)cryptoStream)) |
|||
{ |
|||
streamWriter.Write(plainText); |
|||
} |
|||
|
|||
array = memoryStream.ToArray(); |
|||
} |
|||
} |
|||
} |
|||
return Convert.ToBase64String(array); |
|||
} |
|||
public static string DecryptString(string key, string cipherText) |
|||
{ |
|||
byte[] iv = new byte[16]; |
|||
byte[] buffer = Convert.FromBase64String(cipherText); |
|||
|
|||
using (Aes aes = Aes.Create()) |
|||
{ |
|||
aes.Key = Encoding.UTF8.GetBytes(key); |
|||
aes.IV = iv; |
|||
ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key, aes.IV); |
|||
|
|||
using (MemoryStream memoryStream = new MemoryStream(buffer)) |
|||
{ |
|||
using (CryptoStream cryptoStream = new CryptoStream((Stream)memoryStream, decryptor, CryptoStreamMode.Read)) |
|||
{ |
|||
using (StreamReader streamReader = new StreamReader((Stream)cryptoStream)) |
|||
{ |
|||
return streamReader.ReadToEnd(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue