/// <summary> /// Decrypt method implementation /// </summary> public override byte[] Decrypt(byte[] data, string description = "") { try { byte[] Hdr = GetHeader(data); if (Hdr.SequenceEqual(new byte[] { 0x17, 0xD3, 0xF4, 0x2B })) // RSA { using (RSASystemEncryption enc = new RSASystemEncryption()) { return(enc.Decrypt(data)); } } else if (Hdr.SequenceEqual(new byte[] { 0x17, 0xD3, 0xF4, 0x2A })) // AES256 { using (AESSystemEncryption enc = new AESSystemEncryption()) { return(enc.Decrypt(data)); } } else { return(data); } } catch { return(data); } }
/// <summary> /// Encrypt method implementation /// </summary> public override byte[] Encrypt(byte[] data, string description = "") { try { if (CngKey.Exists(SystemUtilities.SystemKeyName, KeyStorageProvider, CngKeyOpenOptions.MachineKey)) { using (RSASystemEncryption enc = new RSASystemEncryption()) { return(enc.Encrypt(data, description)); } } else { using (AESSystemEncryption enc = new AESSystemEncryption()) { return(enc.Encrypt(data, description)); } } } catch { return(data); } }