简单的加密解密


//C#
//加密,按UTF8加密,安卓才能解析
private string BBEncrypt(string password)
{
	password = "H" + password + "K";
	byte[] bytes = new UTF8Encoding().GetBytes(password);
	return Convert.ToBase64String(bytes);
}

//解密
private string BBDecrypt(string strEncrypt)
{
	byte[] bytes2 = Convert.FromBase64String(strEncrypt);
	return new UTF8Encoding().GetString(bytes2);
}

//Android
// 加密,安卓是按UTF8加密的
String encode(String mima) {
	byte[] _tmp = Base64.encode(mima.getBytes(), Base64.DEFAULT);
	return new String(_tmp);
}

// 解密,安卓是按UTF8解密的
String decode(String mima) {
	byte[] _tmp = Base64.decode(mima, Base64.DEFAULT);
	return new String(_tmp);
}

猜你喜欢

转载自zheyiw.iteye.com/blog/2108294