public static string GetDecrypted(this string bas64String) { var encrypted = Base64Helper.Base64ToString(bas64String); var decryptedText = Encryptor.Decrypt(encrypted); return(decryptedText); }
public String Print(HttpListenerContext context) { HttpListenerPostParaHelper httppost = new HttpListenerPostParaHelper(context); byte[] fileContent = new byte[] { }; String content = httppost.get("data").Substring(httppost.get("data").IndexOf(',') + 1); String type = httppost.get("type"); String printName = httppost.get("printName"); int rawKind = Convert.ToInt32(httppost.get("rawKind")); try { switch (httppost.get("mode")) { case "base64": fileContent = Base64Helper.Base64ToString(content); break; case "file": default: fileContent = FileHelper.FileToBytes(content); break; } String path = System.Environment.CurrentDirectory + "\\Temp\\" + DateTime.Now.ToString("yyyyMMdd") + "\\"; String filename = path + System.Guid.NewGuid().ToString() + "." + type; FileHelper.CreateDirectory(path); FileHelper.CreateFile(filename, fileContent); Print print = new Print(printName, rawKind); print.set(filename, type); Thread thread = new Thread(start: new ThreadStart(print.run)); thread.Start(); } catch (Exception e) { return("打印失败:" + e.Message); } return("打印成功"); }
/// <summary> /// 将Base64编码解析成字符串 /// </summary> /// <param name="strbase">要解码的string字符</param> /// <param name="encoding">字符编码方案</param> /// <returns>字符串</returns> public static string Base64ToString(string strbase, Encoding encoding) { return(Base64Helper.Base64ToString(strbase, encoding)); }