110,567
社区成员
发帖
与我相关
我的任务
分享
public static string HexToBase64(string hexStr)
{
MatchCollection mc = Regex.Matches(hexStr.ToString(), "[A-F0-9]{2}");
byte[] bytes = new byte[mc.Count];
for (int i = 0; i < mc.Count; i++)
{
bytes[i] = byte.Parse(mc[i].Value, System.Globalization.NumberStyles.HexNumber);
}
return Convert.ToBase64String(bytes);
}
import re
import base64
def HexToBase64(hexStr):
reg = re.compile("[A-F0-9]{2}")
matches = reg.findall(hexStr)
bytes = bytearray(0)
for m in matches:
b = int(m,16)
bytes.append(b)
return base64.b64encode(bytes)
import re
import base64
s = "%E6%88%91"
pattern1 = re.compile("[A-F0-9]{2}")
a= pattern1.findall(s)
aa = bytearray(len(a))
for L in a:
n = int(L,16)
aa.append(n)
s = str(aa,'utf-8');print(s)
print(base64.b64encode(aa))
import re
import base64
s = "F0&0F"
pattern1 = re.compile("[A-F0-9]{2}")
a= pattern1.findall(s)
aa = []
for L in a:
n = int(L,16)
aa.append(n)
s = str(aa,'utf-8')
print(base64.b64encode(s))