zoukankan
html css js c++ java
加码解码
public
string
EncodingSMS(
string
s)
{
string
result
=
string
.Empty;
byte
[] arrByte
=
System.Text.Encoding.GetEncoding(
"
GB2312
"
).GetBytes(s);
for
(
int
i
=
0
; i
<
arrByte.Length; i
++
)
{
result
+=
System.Convert.ToString(arrByte[i],
16
);
//
Convert.ToString(byte, 16)把byte转化成十六进制string
}
return
result;
}
public
string
DecodingSMS(
string
s)
{
string
result
=
string
.Empty;
byte
[] arrByte
=
new
byte
[s.Length / 2
];
int
index
=
0
;
for
(
int
i
=
0
; i
<
s.Length; i
+=
2
)
{
arrByte[index
++
]
=
Convert.ToByte(s.Substring(i,
2
),
16
);
//
Convert.ToByte(string,16)把十六进制string转化成byte
}
result
=
System.Text.Encoding.Default.GetString(arrByte);
return
result;
}
加码解码的规则如下:
加码时将字符串中的所有字符转换成其对应的ASCII值的16进制值,例如:“A”的ASCII码值为65,以16进制值表示为41,故应发送两个字符“41”以代表字符“A”。
对于汉字则以其内码的16进制值来表示,如“测试”应为:B2E2CAD4。
原理:
string
aaa
=
"
AB测试
"
;
byte
[] bbb
=
System.Text.Encoding.Default.GetBytes(aaa);
string
ccc
=
System.Text.Encoding.Default.GetString(bbb);
for
(
int
i
=
0
; i
<
bbb.Length; i
++
)
{
Response.Write(System.Convert.ToString(bbb[i],
16
));
}
Response.Write(ccc);
查看全文
相关阅读:
linux 备份当前文件
zz Apache 2.2.15 + PHP 5.3.2+ mysql windows环境配置
zz iframe父子窗口间js方法调用
批处理命令里获取本机的机器名
Cache Concurrency Problem False Sharing
因为添加assembly到GAC引起的Windows Azure Web Role部署失败
求数组中满足a[i]<a[j]的相距最远的元素
Dispose模式
比较汇编指令 LEA 和 MOV
读写Unicode字符串(UTF8,UTF16…)
原文地址:https://www.cnblogs.com/xiaodi/p/145493.html
最新文章
修改SqlServer中对象架构(表架构)示例
类型和类别
理解ASP.NET MVC中的ActionResult
entity framework 数据库默认时间的问题的一种解决方案
mvc3删除前提示
ef 下的并发处理
JavaScript 图片切割效果(带拖放、缩放效果)
IIS中实现http自动转换到https
同一张表分类显示sql 语句
Android,HTTP请求中文乱码
热门文章
Android HTTP session && cookie
android中listview分页加载数据 .
让innerText在firefox火狐和IE浏览器都能用的写法
zz 用JS控制Iframe鼠标的中轴滚动事件,并使鼠标在ifrme内时,父窗口滚动失效
[原创] 配置服务器流水记录(精)
从3个科技公司里学到的57条经验(轉載)
zz FLEX的动画
删掉桌面蓝牙图标
【转】 ActionScript 3 和 Flex框架的性能优化
ZZ flex preloader
Copyright © 2011-2022 走看看