Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using System;
using PX.Data;
using PX.Objects.IN;
using PX.DataSync;
using PX.Common.Cryptography;
using System.Security.Cryptography;
using System.Web.Configuration;
using System.Text;
namespace MyProject
public class EncryptedACHProvider : ACHProvider
public override string ProviderName
return "Encrypted ACH";
protected override PX.SM.FileInfo SetFile(byte[] bytes)
SymmetricCryptoProvider provider = CreateSymetricProvider();
bytes = provider.Encrypt(bytes);
return base.SetFile(bytes);
private static SymmetricCryptoProvider CreateSymetricProvider()
MachineKeySection keySection = (MachineKeySection)WebConfigurationManager.GetSection("system.web/machineKey");
TripleDESCryptoServiceProvider provider = new TripleDESCryptoServiceProvider();
byte[] IV = new byte[provider.IV.Length];
Array.Copy(CryptoProvider.HexStringToByteArray(keySection.DecryptionKey), IV, IV.Length);
byte[] key = new byte[provider.Key.Length];
Array.Copy(CryptoProvider.HexStringToByteArray(keySection.ValidationKey), key, key.Length);
return new SymmetricCryptoProvider(
provider.CreateEncryptor(key, IV),
provider.CreateDecryptor(key, IV));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.