public string build() { //if (!Utils.isUUID(this.appId)) //{ // return ""; //} //if (!Utils.isUUID(this.appCertificate)) //{ // return ""; //} this._messageRawContent = Utils.pack(this.message); this._signature = generateSignature(_appCertificate , _appId , _channelName , _uid , _messageRawContent); this._crcChannelName = Crc32Algorithm.Compute(this._channelName.GetByteArray()); this._crcUid = Crc32Algorithm.Compute(this._uid.GetByteArray()); PackContent packContent = new PackContent(_signature, _crcChannelName, _crcUid, this._messageRawContent); byte[] content = Utils.pack(packContent); return getVersion() + this._appId + Utils.base64Encode(content); }
public bool fromString(string token) { if (!getVersion().Equals(token.Substring(0, Utils.VERSION_LENGTH))) { return(false); } this._appId = token.Substring(Utils.VERSION_LENGTH, Utils.APP_ID_LENGTH); PackContent packContent = new PackContent(); Utils.unpack(Utils.base64Decode(token.Substring(Utils.VERSION_LENGTH + Utils.APP_ID_LENGTH)), packContent); this._signature = packContent.signature; this._crcChannelName = packContent.crcChannelName; this._crcUid = packContent.crcUid; this._messageRawContent = packContent.rawMessage; Utils.unpack(this._messageRawContent, message); return(true); }