1.8.0和1.8.1的乌龙
来源:互联网 发布:淘宝云客服返岗论坛 编辑:程序博客网 时间:2024/04/29 15:43
下Subversion的时候看见他家主页上的SHA1验证心血来潮,当是复习Java自己写一个SHA1的验证程序。调用的当然是非常简单易用的MessageDigest。
public class MessageDigestCheckSumValidator extends CheckSumValidator {private String algorithm="";private DigestInputStream digestInputStream =null;private MessageDigest messageDigest = null;protected DigestInputStream getDigestInputStream() {return digestInputStream;}protected void setDigestInputStream(DigestInputStream dis) {this.digestInputStream = dis;}protected MessageDigest getMessageDigest() {return messageDigest;}protected void setMessagedigest(MessageDigest md) {this.messageDigest = md;}protected String getAlgorithm() {return algorithm;}protected void setAlgorithm(String algorithm) {this.algorithm = algorithm;}public MessageDigestCheckSumValidator (String targetCheckSum, InputStream inputStream, String algorithm){this.setTargetCheckSum(targetCheckSum);this.setInputStream(inputStream);this.setAlgorithm(algorithm);}protected String byteArrtoHexaDecimal(byte[] bytes){StringBuffer sb = new StringBuffer();for (int i=0; i<bytes.length; i++){sb.append(Integer.toString((bytes[i]&0xff)+0x100,16).substring(1));}return sb.toString();}@Overrideprotected boolean validateCheckSum() {BufferedInputStream bis =null;try{this.setMessagedigest(MessageDigest.getInstance(this.getAlgorithm()));bis = new BufferedInputStream(this.getInputStream());this.setDigestInputStream(new DigestInputStream(bis,this.getMessageDigest()));while(this.digestInputStream.read()!=-1);byte[] bytes = this.getMessageDigest().digest();String hexaDemicalCheckSumStr = this.byteArrtoHexaDecimal(bytes);if (this.getTargetCheckSum().equals(hexaDemicalCheckSumStr)){return true;}else{return false;}}catch(NoSuchAlgorithmException e){e.printStackTrace();return false;}catch(IOException e){e.printStackTrace();return false;}finally{if(bis!=null){try{bis.close();}catch(IOException e){e.printStackTrace();}}}}}
结果用Junit跑了个测试竟然木有通过。。。人家网站上的校验码是12261a97df5cdc53175cba813ea451937a226bca,可跑出来是6f2b4476b8d8b9f2700ae101252bdf6e67366302。换了两三种ByteArray2HexaDecimal的方法,结果还是一样。
百思不得骑姐的情况下,从网上搜索了两个程序进行对照,结果竟然也同样是6f2b4476b8d8b9f2700ae101252bdf6e67366302。
看来要出动google大神了,突然就想到用这个“错误”的校验码看看能搜到什么东西。
竟然有一个版本的校验法就是6f2b4476b8d8b9f2700ae101252bdf6e67366302,再凝神一看svn的版本号,再对一下svn官方网站上的版本号,乌龙就这么诞生了。。。一直以为下的是1.8.1结果神使鬼差的一直在对1.8.0做校验。重新下载,再跑,通过了。
- 1.8.0和1.8.1的乌龙
- 乌龙的淘宝
- 1月份那些挨踢的乌龙事
- 一次乌龙的数据库升级
- [乌龙]kde4.1.1和scim有冲突
- 微软 DirectShow 的自摆乌龙
- 乌龙呀,中了assert的招
- windows sdk的乌龙之directx sdk
- 乌龙引擎的功能,iPhone开发者
- 乌龙姐 mysql的sb纪实
- ogg-00869的一个乌龙事件
- 减肥减不掉的“乌龙指”/恐龙难道是笨死的?
- Delphi里使用SPComm串口控件的一个乌龙BUG
- LaTeX中设置目录显示深度的一次乌龙经历
- Nvidia-SDK-Code-Sample的学习[5]OverLap、一次乌龙
- 记一次网站渗透乌龙引发的头脑风暴
- 2017年AI领域的十大乌龙事件
- 本泽马两球造乌龙 法国3-0胜10人洪都拉斯
- EJB到底是什么,真的那么神秘吗??
- MySQL数据库引擎ISAM,myISAM,heap
- poj1703 犯罪集团 并査集
- ubuntu12.10 MTK GCC4.4.3
- 《原子核结构新理论》--没有公开发表的原子核物理遗作
- 1.8.0和1.8.1的乌龙
- 一个计算器calculator的界面(初级)没有任何功能,只为熟悉GUI的awt的各种用法
- Phone List
- 关于我们CSDN
- ecc安装过程
- 黑马程序员——.NET自学笔记4_流程控制
- CString转char * ,string
- 算法导论堆排序Java实现
- object-c的id