public ArrayByte SetArray(ArrayByte uarr, int offset) { int max = uarr.Length() < (this.Length() - offset) ? uarr.Length() : (Length() - offset); this.Write(uarr.data, offset, max); return(this); }
public sbyte[] GetBytes() { long[] items = this.items; ArrayByte bytes = new ArrayByte(items.Length * 8); for (int i = 0; i < items.Length; i++) { bytes.WriteLong(items[i]); } return(bytes.GetBytes()); }
public sbyte[] GetBytes(int order) { bool[] items = this.items; ArrayByte bytes = new ArrayByte(items.Length); bytes.SetOrder(order); for (int i = 0; i < items.Length; i++) { bytes.WriteBoolean(items[i]); } return(bytes.GetBytes()); }
public ArrayByte Slice(int begin, int end) { if (end == -1) { end = this.Length(); } int len = end - begin; ArrayByte bytes = new ArrayByte(len); bytes.Write(this.data, begin, len); return(bytes); }
public static ArrayByte CryptData(string key, ArrayByte value) { try { ARC4 rc4 = new ARC4(key); return(rc4.GetCrypt(value)); } catch (Throwable) { return(value); } }
public sbyte[] GetBytes(int order) { char[] items = this.items; int size = items.Length; ArrayByte bytes = new ArrayByte(size * 2); bytes.SetOrder(order); for (int i = 0; i < size; i++) { bytes.WriteChar(items[i]); } return(bytes.GetBytes()); }
public static ArrayByte EncodeUTF8(string str, int orderType) { int offset = 0; int c1 = 0; int c2 = 0; IntArray buffer = new IntArray(GetUTF8ByteLength(str)); for (int i = 0; i < str.Length(); i++) { c1 = str.CharAt(i); if (c1 < 128) { buffer.Set(offset++, c1); } else if (c1 < 2048) { buffer.Set(offset++, c1 >> 6 | 192); buffer.Set(offset++, c1 & 63 | 128); } else if ((c1 & 0xFC00) == 0xD800 && ((c2 = str.CharAt(i + 1)) & 0xFC00) == 0xDC00) { c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF); ++i; buffer.Set(offset++, c1 >> 18 | 240); buffer.Set(offset++, c1 >> 12 & 63 | 128); buffer.Set(offset++, c1 >> 6 & 63 | 128); buffer.Set(offset++, c1 & 63 | 128); } else { buffer.Set(offset++, c1 >> 12 | 224); buffer.Set(offset++, c1 >> 6 & 63 | 128); buffer.Set(offset++, c1 & 63 | 128); } } ArrayByte bytes = new ArrayByte(offset); bytes.SetByteOrder(orderType); for (int i = 0; i < offset; i++) { bytes.WriteByte(buffer.Get(i)); } return(bytes); }
public string EncryptBytes(ArrayByte arrays) { return(EncryptBytes(arrays.GetData())); }
public ArrayByteOutput(int size) { _buffer = new ArrayByte(size); }
public ArrayByte GetCrypt(ArrayByte input) { sbyte[] output = new sbyte[input.Available()]; Crypt(input.GetData(), output); return(new ArrayByte(output)); }
public ARC4(ArrayByte key) : this(key.GetData()) { }