erlang md5 16进制字符串
2015-12-04 16:22
253 查看
搜索到的访问量最高是这个: http://blog.csdn.net/zhangxinrun/article/details/7741373
思路: 把16个byte, 每个byte变成16进制不就行了么? 但是需要补0, 例如 0x7 ==> 0x07.
我不禁想 设计erlang的人那么蠢么? 类似 %02x 的也没有么?
看看官方文档果然有:
The general format of a control sequence is ~F.P.PadModC. The character C determines
the type of control sequence to be used, F and P are optional numeric arguments. If F, P,
or Pad is *, the next argument in Data is used as the numeric value
of F or P.
F is the field width of the printed argument. A negative
value means that the argument will be left justified within the field, otherwise it will be right justified. If no field width is specified, the required print width will be used. If the field width specified is too small, then the whole field will be filled
with * characters.
P is the precision of the printed argument. A default value
is used if no precision is specified. The interpretation of precision depends on the control sequences. Unless otherwise specified, the argument within is used to determine print width.
Pad is the padding character. This is the character used to pad the printed representation of the argument so that it conforms
to the specified field width and precision. Only one padding character can be specified and, whenever applicable, it is used for both the field width and precision. The default padding character is '
' (space).
Mod is the control sequence modifier. It is either a single character (currently only 't', for unicode translation, is
supported) that changes the interpretation of Data.
几行代码搞定:
Sig = erlang:md5("123").
binary_to_list(iolist_to_binary([io_lib:format("~2.16.0b", [S]) || S <- binary_to_list(Sig)])).
"202cb962ac59075b964b07152d234b70"
思路: 把16个byte, 每个byte变成16进制不就行了么? 但是需要补0, 例如 0x7 ==> 0x07.
我不禁想 设计erlang的人那么蠢么? 类似 %02x 的也没有么?
看看官方文档果然有:
The general format of a control sequence is ~F.P.PadModC. The character C determines
the type of control sequence to be used, F and P are optional numeric arguments. If F, P,
or Pad is *, the next argument in Data is used as the numeric value
of F or P.
F is the field width of the printed argument. A negative
value means that the argument will be left justified within the field, otherwise it will be right justified. If no field width is specified, the required print width will be used. If the field width specified is too small, then the whole field will be filled
with * characters.
P is the precision of the printed argument. A default value
is used if no precision is specified. The interpretation of precision depends on the control sequences. Unless otherwise specified, the argument within is used to determine print width.
Pad is the padding character. This is the character used to pad the printed representation of the argument so that it conforms
to the specified field width and precision. Only one padding character can be specified and, whenever applicable, it is used for both the field width and precision. The default padding character is '
' (space).
Mod is the control sequence modifier. It is either a single character (currently only 't', for unicode translation, is
supported) that changes the interpretation of Data.
几行代码搞定:
Sig = erlang:md5("123").
binary_to_list(iolist_to_binary([io_lib:format("~2.16.0b", [S]) || S <- binary_to_list(Sig)])).
"202cb962ac59075b964b07152d234b70"
相关文章推荐
- DevExpress 2015.2发布 看看有哪些更新
- popToViewController和dismissviewcontroller的用法
- iOS 发大招 otherButtonTitles:(nullable NSString *)otherButtonTitles, ... 写法 && 编写通用类的时候关于可变参数的处理
- auv的设计
- 堆排序
- Spring MVC入门1
- 如何使用css3绘制任意角度扇形+动画
- Android app智能升级(增量更新)_AndroidStudio
- 【转载】Android样式的开发:View Animation篇
- 解决国内pip安装速度慢的问题
- mybatis jdbcType: DATE ,TIMESTAMP 区别:
- 【OpenCV】问题集锦【imread(),imshow()】
- iOS开发技巧--项目中定义宏的相关方法
- 声明中"AutoEventWireup"、"Codebehind"、"Inherits"分别表示什么意思?
- 算法作业5
- GC调优在Spark应用中的实践
- android的org.json.JSONObject的getXXX方法
- 分享给大家一个生成图形验证码的View
- myelcipse中SVN进行代码更新和提交
- 8天学通MongoDB——第七天 运维技术