![](/img/trans.png)
[英]How to convert a string to base64 encoding using byte array in JavaScript?
[英]Secure way to convert a byte array to SecureString with Base64 encoding
我有一個byte[]
需要用 Base64 編碼並作為SecureString
返回。 我目前的代碼如下:
string privateString = Convert.ToBase64String(byteArray);
SecureString result = new SecureString();
foreach (char c in privateString)
{
result.AppendChar(c);
}
// wipe the byte array...
問題是調用Convert.ToBase64String
並不安全,因為它創建了一個我無法銷毀的托管字符串。 有沒有安全的方法來做到這一點?
在沒有中間字符串的情況下編碼 base-64 數據的方法: System.Buffers.Text.Base64
。 然而! SecureString
不安全,現在基本上不應該使用。 曾經。 它無法針對任何有意義的攻擊實現任何有用的保護。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.