Beispiel #1
0
        public override void encrypt(MemoryStream stream)
        {
            int padSize = 0;

            if (stream.length() % BLOCK_SIZE != 0)
            {
                padSize      = (int)(BLOCK_SIZE - (stream.length() % BLOCK_SIZE));
                stream.wpos += padSize;

                if (stream.wpos > MemoryStream.BUFFER_MAX)
                {
                    Debug.LogError("BlowfishFilter::encrypt: stream.wpos(" + stream.wpos + ") > MemoryStream.BUFFER_MAX(" + MemoryStream.BUFFER_MAX + ")!");
                }
            }

            _blowfish.encipher(stream.data(), (int)stream.length());

            UInt16 packLen = (UInt16)(stream.length() + 1);

            _enctyptStrem.writeUint16(packLen);
            _enctyptStrem.writeUint8((UINT8)padSize);
            _enctyptStrem.append(stream.data(), (UInt32)stream.rpos, stream.length());

            stream.swap(_enctyptStrem);
            _enctyptStrem.clear();
        }
Beispiel #2
0
        public override void encrypt(MemoryStream stream)
        {
            int padSize = 0;

            if (stream.length() % BLOCK_SIZE != 0)
            {
                padSize      = (int)(BLOCK_SIZE - (stream.length() % BLOCK_SIZE));
                stream.wpos += padSize;
                Debug.Assert(stream.wpos <= MemoryStream.BUFFER_MAX);
            }

            _blowfish.encipher(stream.data(), (int)stream.length());

            UInt16 packLen = (UInt16)(stream.length() + 1);

            _enctyptStrem.writeUint16(packLen);
            _enctyptStrem.writeUint8((UINT8)padSize);
            _enctyptStrem.append(stream.data(), (UInt32)stream.rpos, stream.length());

            stream.swap(_enctyptStrem);
            _enctyptStrem.clear();
        }