將原文件讀取為字節數組,然后用base64加密,得到加密的字符串
https://stackoverflow.com/questions/475421/base64-encode-a-pdf-in-c
Use File.ReadAllBytes
to load the PDF file, and then encode the byte array as normal using Convert.ToBase64String(bytes)
.
將加密后的字符串,直接寫到文件中
https://stackoverflow.com/questions/24808014/convert-base64-encoding-to-pdf
byte[] sPDFDecoded = Convert.FromBase64String(base64BinaryStr); File.WriteAllBytes(@"c:\Users\u316383\Documents\pdf8.pdf", sPDFDecoded);