コード例 #1
0
ファイル: FixedXor.cs プロジェクト: alexjneves/MatasanoCrypto
        public FixedXor(HexString first, HexString second)
        {
            if (first.Hex.Length != second.Hex.Length)
            {
                throw new FixedXorException("String lengths are not equal");
            }

            var firstByteArray  = new HexToBytesConverter(first);
            var secondByteArray = new HexToBytesConverter(second);

            var length = firstByteArray.Bytes.Length;

            var xorBytes = new byte[length];

            for (var i = 0; i < length; ++i)
            {
                xorBytes[i] = (byte)(firstByteArray.Bytes[i] ^ secondByteArray.Bytes[i]);
            }

            _result = new BytesToHexConverter(xorBytes).HexString;
        }
コード例 #2
0
        public HexToBase64Encoder(HexString hex)
        {
            var bytes = new HexToBytesConverter(hex).Bytes;

            _base64 = Encode(bytes.ToList());
        }