using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace System.Fire.Container { public class ContainerKey { private byte[] _k; public ContainerKey() { } public ContainerKey(byte[] Key) { this._k = Key; } public byte[] Key { get { return this._k; } set { this._k = value; } } public byte GetAt(int index) { return this._k[index % this._k.Length]; } public int Length { get { return this._k.Length; } } public static byte[] operator |(ContainerKey key, byte[] s) { byte[] res = new byte[s.Length]; for (int i = 0, c = s.Length; i < c; i++) res[i] = (byte)(s[i] | key.GetAt(i)); return res; } public static byte[] operator &(ContainerKey key, byte[] s) { byte[] res = new byte[s.Length]; for (int i = 0, c = s.Length; i < c; i++) res[i] = (byte)(s[i] & key.GetAt(i)); return res; } public static byte[] operator ^(ContainerKey key, byte[] s) { byte[] res = new byte[s.Length]; for (int i = 0, c = s.Length; i < c; i++) res[i] = (byte)(s[i] ^ key.GetAt(i)); return res; } public static byte[] operator |(ContainerKey key, string s) { return key | System.Text.ASCIIEncoding.Default.GetBytes(s); } public static byte[] operator &(ContainerKey key, string s) { return key & System.Text.ASCIIEncoding.Default.GetBytes(s); } public static byte[] operator ^(ContainerKey key, string s) { return key ^ System.Text.ASCIIEncoding.Default.GetBytes(s); } } }