public void WriteString(core.LinkHub.Leaf leaf, String text, bool null_terminated) { byte[] data = Encoding.UTF8.GetBytes(text); data = Crypto.Encrypt(data, leaf.Key, leaf.IV); this.WriteUInt16((ushort)data.Length); this.WriteBytes(data); if (null_terminated) { this.Data.Add(0); } }
public String ReadString(core.LinkHub.Leaf leaf) { String str = String.Empty; ushort size = this; byte[] data = this.ReadBytes(size); data = Crypto.Decrypt(data, leaf.Key, leaf.IV); str = Encoding.UTF8.GetString(data); if (this.Position < this.Data.Count) { if (this.Data[this.Position] == 0) { this.Position++; } } foreach (String c in bad_chars) { str = Regex.Replace(str, Regex.Escape(c), "", RegexOptions.IgnoreCase); } return(str.Trim()); }
public void WriteString(core.LinkHub.Leaf leaf, String text) { this.WriteString(leaf, text, true); }