簡體   English   中英

Byte [32]使用Convert.ToBase64String(byteValue32)轉換為字符串,但與Encoding.ASCII.GetBytes(string)相反,成為byte [44]

[英]Byte[32] converts to string with Convert.ToBase64String(byteValue32) but to go opposite the Encoding.ASCII.GetBytes(string) becomes byte[44]

所以看起來轉換不一樣

byte[] salt;  // this i hover over and see {byte[32]}  
string saltText = Convert.ToBase64String(salt);
// This saltText come out with the string

// example is that saltText = puYwD1RHO9mdrg4eakJIskcrN4wPlxzkBwjdwyJL+Eg=

這部分很好,但是我需要將其轉換回來,所以我做到了

byte[] saltArray = Encoding.ASCII.GetBytes(saltText);

// Hover over and the saltArray is saying {byte[44]}  

我不了解字節嗎? 為什么從32變為44

試試這個解碼

var base64EncodedBytes = System.Convert.FromBase64String(salt);
var stringData = System.Text.Encoding.UTF8.GetString(base64EncodedBytes);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM