Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
 static int writeUint8(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         KBEngine.MemoryStream obj = (KBEngine.MemoryStream)ToLua.CheckObject <KBEngine.MemoryStream>(L, 1);
         byte arg0 = (byte)LuaDLL.luaL_checknumber(L, 2);
         obj.writeUint8(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
 public void writeUint8(Byte v)
 {
     checkStream(1);
     stream.writeUint8(v);
 }