public IActionResult Post([FromBody] DecodeParam param) { if (param == null || string.IsNullOrWhiteSpace(param.Code)) { _logger.LogError("No param in decoding."); return(BadRequest("no param")); } var code = param.Code.Trim(); if (code.Length > _decodeMaxLength) { _logger.LogError("Decoding param too long: {0}", code.Length); return(BadRequest("param too long")); } try { var sourceAes = EncodeTool.StringToByteArray(code); var source = AESTool.Decrypt(sourceAes); var sourceStr = Encoding.UTF8.GetString(source); _logger.LogInformation("Decoding successfully.\nCode: {0} \nSource: {1}", code, sourceStr); return(new JsonResult(new DecodeResult() { Source = sourceStr })); } catch (Exception ex) { _logger.LogError("Decoding error for string:\n {0} \nError: {1}", code, ex.Message); return(BadRequest("decode error")); } }
private static Dictionary <string, string> GetVersions(AssetBundleManifest manifest) { var items = manifest.GetAllAssetBundles(); Dictionary <string, string> dicRet = items.ToDictionary(item => item, item => manifest.GetAssetBundleHash(item).ToString()); /////////////////////////////////////////增加byte dll的文件/////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////增加byte dll的文件/////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////增加byte dll的文件/////////////////////////////////////////////////////////////////////////////////////////////// dicRet.Add(LWUtility.HotfixFileName, AESTool.GetHash(Application.streamingAssetsPath + "/Hotfix/" + LWUtility.HotfixFileName)); return(dicRet); }
public IActionResult Post([FromBody] EncodeParam param) { _logger.LogDebug("Start Encoding."); if (param == null || string.IsNullOrWhiteSpace(param.Source)) { _logger.LogError("No param in encoding."); return(BadRequest("no param")); } var source = param.Source.Trim(); if (source.Length > _encodeMaxLength) { _logger.LogError($"Encoding param too long: {source.Length}"); return(BadRequest("param too long")); } var remoteIP = Request.HttpContext.Connection.RemoteIpAddress.ToString(); try { var sourceAes = AESTool.Encrypt(Encoding.UTF8.GetBytes(source)); var code = EncodeTool.ByteArrayToString(sourceAes); //var testaes = EncodeTool.StringToByteArray(code); //if (testaes.Length != sourceAes.Length) //{ // for (var i = 0; i < testaes.Length; i++) // { // if (testaes[i] != sourceAes[i]) // { // _logger.LogError($"Encoding error in {i} of {sourceAes.Length}"); // break; // } // } //} _logger.LogInformation($"(IP:{remoteIP})Encoding successfully.\nSource: {source} \nCode: {code}"); return(new JsonResult(new EncodeResult() { Code = code })); } catch (Exception ex) { _logger.LogError($"(IP:{remoteIP})Encoding error for string: \n{source} \nError:{ex.Message}"); return(BadRequest("encode error")); } }
public IActionResult Post([FromBody] EncodeParam param) { _logger.LogDebug("Start Encoding."); if (param == null || string.IsNullOrWhiteSpace(param.Source)) { _logger.LogError("No param in encoding."); return(BadRequest("no param")); } var source = param.Source.Trim(); if (source.Length > _encodeMaxLength) { _logger.LogError("Encoding param too long: {0}", source.Length); return(BadRequest("param too long")); } try { var sourceAes = AESTool.Encrypt(Encoding.UTF8.GetBytes(source)); var code = EncodeTool.ByteArrayToString(sourceAes); var testaes = EncodeTool.StringToByteArray(code); if (testaes.Length != sourceAes.Length) { for (var i = 0; i < testaes.Length; i++) { if (testaes[i] != sourceAes[i]) { _logger.LogError("Encoding error in {0} of {1}", i, sourceAes.Length); break; } } } _logger.LogInformation("Encoding successfully.\nSource: {0} \nCode: {1}", source, code); return(new JsonResult(new EncodeResult() { Code = code })); } catch (Exception ex) { _logger.LogError("Encoding error for string: \n{0} \nError:{1}", source, ex.Message); return(BadRequest("encode error")); } }