public string DecryptText(string cipherText, SecuritySettings securitySettings = null, string encryptionPrivateKey = null) { if (string.IsNullOrEmpty(cipherText)) return cipherText; if (string.IsNullOrEmpty(encryptionPrivateKey)) { if (securitySettings == null) securitySettings = EngineContext.Current.Resolve<SecuritySettings>(); encryptionPrivateKey = securitySettings.EncryptionKey; } var tDESalg = new TripleDESCryptoServiceProvider(); tDESalg.Key = new ASCIIEncoding().GetBytes(encryptionPrivateKey.Substring(0, 16)); tDESalg.IV = new ASCIIEncoding().GetBytes(encryptionPrivateKey.Substring(8, 8)); byte[] buffer = Convert.FromBase64String(cipherText); return DecryptTextFromMemory(buffer, tDESalg.Key, tDESalg.IV); }
public CustomerRegistrationService(ICustomerService customerService, IEncryptionService encryptionService, INewsLetterSubscriptionService newsLetterSubscriptionService, ILocalizationService localizationService, IStoreService storeService, RewardPointsSettings rewardPointsSettings, CustomerSettings customerSettings, SecuritySettings securitySettings) { _customerService = customerService; _encryptionService = encryptionService; _newsLetterSubscriptionService = newsLetterSubscriptionService; _localizationService = localizationService; _storeService = storeService; _rewardPointsSettings = rewardPointsSettings; _customerSettings = customerSettings; _securitySettings = securitySettings; }
public string EncryptText(string plainText, SecuritySettings securitySettings = null, string encryptionPrivateKey = null) { if (string.IsNullOrEmpty(plainText)) return plainText; if (string.IsNullOrEmpty(encryptionPrivateKey)) { // ghi chú: có thể đẩy vai trò lấy securitySettings.EncryptionKey ra ngoài, từ đó biến đối tượng thành singleton // 23/10/15: OK, chơi lun, chuyển hóa nó thành singleton if (securitySettings == null) securitySettings = EngineContext.Current.Resolve<SecuritySettings>(); encryptionPrivateKey = securitySettings.EncryptionKey; } var tDESalg = new TripleDESCryptoServiceProvider(); tDESalg.Key = new ASCIIEncoding().GetBytes(encryptionPrivateKey.Substring(0, 16)); tDESalg.IV = new ASCIIEncoding().GetBytes(encryptionPrivateKey.Substring(8, 8)); var encryptedBinary = EncryptTextToMemory(plainText, tDESalg.Key, tDESalg.IV); return Convert.ToBase64String(encryptedBinary); }
public override bool CheckEnableXsrfProtection(SecuritySettings securitySettings) { return securitySettings.EnableXsrfProtectionForPublicStore; }
public abstract bool CheckEnableXsrfProtection(SecuritySettings securitySettings);