-5
byte[] ba = Encoding.Default.GetBytes(input);
var hexString = BitConverter.ToString(ba);
hexString = hexString.Replace("-", "");
Console.WriteLine("Or: " + hexString + " in hexadecimal");
所以我得到了這個,現在我怎麼會將hexString
轉換爲base64字符串?
我試過this,得到了錯誤:將十六進制字符串轉換爲base64
Cannot convert from string to byte[]
如果該解決方案適用於任何人,我究竟做錯了什麼?我試過這個,但它在第一行返回「不能隱式轉換類型'byte []'爲'string'」,然後「參數1:不能從'字符串'轉換爲'byte []' 「」。
您是否嘗試過Convert.FromBase64String(輸入)呢? – GrandMasterFlush
OP,不要鏈接到其他問題,把你在這篇文章中嘗試過的代碼。請參閱[mcve] – Equalsk
[我如何對base64字符串進行編碼和解碼?]的可能重複(https://stackoverflow.com/questions/11743160/how-do-i-encode-and-decode-a-base64-string ) – tk421