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(); }
static int writeUint16(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); KBEngine.MemoryStream obj = (KBEngine.MemoryStream)ToLua.CheckObject <KBEngine.MemoryStream>(L, 1); ushort arg0 = (ushort)LuaDLL.luaL_checknumber(L, 2); obj.writeUint16(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
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(); }
public void writeUint16(UInt16 v) { checkStream(2); stream.writeUint16(v); }