using System.Text.Json; using System.Text.RegularExpressions; namespace HelloWorld; class Program { static string[] EXTS = { ".txt", ".json",}; static string PATTERN = "\'(.+)\':"; static string IDPATTERN = "ObjectId\\(\"(.+)\"\\)"; static void Main(string[] args) { BytePlusAuthTest(); Console.WriteLine("Press any key..."); Console.ReadLine(); } private static string accessKey = "AKAPZGNkNGYzZmJiNGVmNDUxNjk0MDM5MmI4NDM5MmY5YmY"; private static string secretKey = "WkRjNVpEVTBPVEkyTUdJeU5EUTFZems0TURFeU9UZGxOV1JsTURreFpEYw=="; private static int expirationSeconds = 86400; private static void BytePlusAuthTest() { string method = "POST"; // The requested path. Not a complete URL string uri = "/dataprofile/openapi/v1/751/users/185"; var exampleQueryParams = new Dictionary { { "set_once", "true" } }; string exampleQueryBodyJson = "{\"name\":\"name\",\"value\":\"zhangsan\"}"; string authorization = BytePlusAuthUtils.Sign(accessKey, secretKey, expirationSeconds, method, uri, exampleQueryParams, exampleQueryBodyJson); Console.WriteLine("authorization: " + authorization); } static void Test1(string[] args) { int idx = 0; foreach (var item in args) { Console.WriteLine($"{idx} - {item}"); if (File.Exists(item)) { string ext = Path.GetExtension(item); if (EXTS.Contains(ext)) { string content = File.ReadAllText(item); content = Regex.Replace(content, PATTERN, "\"$1\":"); content = Regex.Replace(content, IDPATTERN, "\"$1\""); if (content != null) { WrapperInfo? wrapper = JsonSerializer.Deserialize(content); if (wrapper != null) { if (wrapper.Cn != null && wrapper.Cn.Length > 0) { wrapper.Cn = StringExtension.Decompress(wrapper.Cn); } if (wrapper.En != null && wrapper.En.Length > 0) { wrapper.En = StringExtension.Decompress(wrapper.En); } Console.WriteLine(wrapper.Cn); Console.WriteLine(wrapper.En); } } } } idx++; } } }