简体   繁体   English

如何解码 .Java 文件中的协议缓冲区字符串

[英]How To Decode Protocol Buffer String in .Java file

I've searched all around for name to call this, but i can't find any.... Its in a .java file sent to me by a friend(He Thought i would decode it straightaway), without knowing i'm also a noob of this.... This is the String data i want to decode without compiling the Java file.我四处寻找名字来称呼这个,但我找不到任何......它在一个朋友发送给我的.java文件中(他认为我会直接解码它),不知道我这也是一个菜鸟......这是我想在不编译Java文件的情况下解码的字符串数据。

String[] descriptorData = {
  "\n0com/google/javascript/jscomp/function_" +
  "info.proto\022\006jscomp\"\277\002\n\026FunctionInformati" +
  "onMap\0223\n\005entry\030\001 \003(\n2$.jscomp.FunctionIn" +
  "formationMap.Entry\0225\n\006module\030e \003(\n2%.jsc" +
  "omp.FunctionInformationMap.Module\032\207\001\n\005En" +
  "try\022\n\n\002id\030\002 \002(\005\022\023\n\013source_name\030\003 \002(\t\022\023\n\013" +
  "line_number\030\004 \002(\005\022\023\n\013module_name\030\005 \002(\t\022\014" +
  "\n\004size\030\006 \002(\005\022\014\n\004name\030\007 \002(\t\022\027\n\017compiled_s" +
  "ource\030\010 \002(\t\032/\n\006Module\022\014\n\004name\030f \002(\t\022\027\n\017c" +
  "ompiled_source\030g \002(\tB \n\034com.google.javas","cript.jscompP\001"

What you see there is if I'm not mistaken a piece of auto generated code that describes如果我没有弄错的话,你看到的是一段自动生成的代码,它描述了

message FunctionInformationMap {
  repeated group Entry = 1 {
    required int32 id = 2;
    required string source_name = 3;
    required int32 line_number = 4;
    required string module_name = 5;
    required int32 size = 6;
    required string name = 7;
    required string compiled_source = 8;
  }
}

It's here https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/function_info.proto它在这里https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/function_info.proto

and the generated code here can be found for example here生成的代码可以在这里找到,例如这里

https://code.google.com/p/closure-compiler/source/browse/gen/com/google/javascript/jscomp/FunctionInfo.java?name=v20140407 https://code.google.com/p/closure-compiler/source/browse/gen/com/google/javascript/jscomp/FunctionInfo.java?name=v20140407

Ps: I just googled "com/google/javascript/jscomp/function_info.proto" but you can actually reverse the process. Ps:我只是在谷歌上搜索了“com/google/javascript/jscomp/function_info.proto”,但你实际上可以逆转这个过程。 Hints here for example https://www.sysdream.com/reverse-engineering-protobuf-apps这里的提示例如https://www.sysdream.com/reverse-engineering-protobuf-apps

I Simply solved this by using the System.Out.PrintIn to print out the string data to a TXT file...我只是通过使用System.Out.PrintIn将字符串数据打印到 TXT 文件来解决这个问题...

That's It.. Thanks...就是这样..谢谢...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM