public static byte[] CombineByteArray(byte[] b1, byte[] b2) { Buf b = new Buf(); if (b1 != null) { b.Write(b1); } if (b2 != null) { b.Write(b2); } return(b.ByteData); }
public Buf Build() { int z; Buf b; this.fileList.Sort(); z = 0; z += HamCore.HamcoreHeaderSize; z += sizeof(int); foreach (HamCoreBuilderFileEntry f in this.fileList) { z += Str.ShiftJisEncoding.GetByteCount(f.Name) + sizeof(int); z += sizeof(int); z += sizeof(int); z += sizeof(int); } foreach (HamCoreBuilderFileEntry f in this.fileList) { f.Offset = z; z += (int)f.CompressedData.Size; } b = new Buf(); b.Write(Str.ShiftJisEncoding.GetBytes(HamCore.HamcoreHeaderData)); b.WriteInt((uint)this.fileList.Count); foreach (HamCoreBuilderFileEntry f in this.fileList) { b.WriteStr(f.Name, true); b.WriteInt(f.RawData.Size); b.WriteInt(f.CompressedData.Size); b.WriteInt((uint)f.Offset); } foreach (HamCoreBuilderFileEntry f in this.fileList) { b.Write(f.CompressedData.ByteData); } b.SeekToBegin(); return(b); }
public byte[] Sign(byte[] data) { Buf b = new Buf(data); b.SeekToEnd(); b.Write(keyData); return(Secure.HashSHA1(b.ByteData)); }
public Buf ToBuf() { string s = ToString(); Buf b = new Buf(); byte[] bom = Str.GetBOM(this.Encoding); if (bom != null) { b.Write(bom); } b.Write(encoding.GetBytes(s)); b.SeekToBegin(); return(b); }
public static byte[] PkcsPadding(byte[] srcData, int destSize) { int srcSize = srcData.Length; if ((srcSize + 11) > destSize) { throw new OverflowException(); } int randSize = destSize - srcSize - 3; byte[] rand = Secure.Rand((uint)randSize); Buf b = new Buf(); b.WriteByte(0x00); b.WriteByte(0x02); b.Write(rand); b.WriteByte(0x00); b.Write(srcData); return(b.ByteData); }
public static byte[] ReadAllFromStream(Stream st) { byte[] tmp = new byte[32 * 1024]; Buf b = new Buf(); while (true) { int r = st.Read(tmp, 0, tmp.Length); if (r == 0) { break; } b.Write(tmp, 0, r); } return(b.ByteData); }
public static Buf ReadFromStream(Stream st) { Buf ret = new Buf(); int size = 32767; while (true) { byte[] tmp = new byte[size]; int i = st.Read(tmp, 0, tmp.Length); if (i <= 0) { break; } Array.Resize <byte>(ref tmp, i); ret.Write(tmp); } ret.SeekToBegin(); return(ret); }
public static byte[] PkcsPadding(byte[] srcData, int destSize) { int srcSize = srcData.Length; if ((srcSize + 11) > destSize) { throw new OverflowException(); } int randSize = destSize - srcSize - 3; byte[] rand = Secure.Rand((uint)randSize); Buf b = new Buf(); b.WriteByte(0x00); b.WriteByte(0x02); b.Write(rand); b.WriteByte(0x00); b.Write(srcData); return b.ByteData; }
public byte[] Sign(byte[] data) { Buf b = new Buf(data); b.SeekToEnd(); b.Write(keyData); return Secure.HashSHA1(b.ByteData); }
public static Buf ReadFromStream(Stream st) { Buf ret = new Buf(); int size = 32767; while (true) { byte[] tmp = new byte[size]; int i = st.Read(tmp, 0, tmp.Length); if (i <= 0) { break; } Array.Resize<byte>(ref tmp, i); ret.Write(tmp); } ret.SeekToBegin(); return ret; }
public void ReadToBuf(Buf buf, int size) { byte[] data = Read(size); buf.Write(data); }
public void ReadToBuf(Buf buf, int size) { byte[] data = Read(size); buf.Write(data); }
public Buf ToBuf() { string s = ToString(); Buf b = new Buf(); byte[] bom = Str.GetBOM(this.Encoding); if (bom != null) { b.Write(bom); } b.Write(encoding.GetBytes(s)); b.SeekToBegin(); return b; }