Produced by Araxis Merge on 6/11/2019 10:54:17 AM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\fw\util | HashUtils.java | Wed May 29 15:26:00 2019 UTC |
| 2 | HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\fw\util | HashUtils.java | Mon Jun 10 19:30:05 2019 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 114 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | /********* ********** ********** ********** ********** ********** ********* | |
| 2 | * Copyrii ght 2009 V HA. All ri ghts reser ved | |
| 3 | ********* ********** ********** ********** ********** ********** *********/ | |
| 4 | ||
| 5 | package go v.va.med.f w.util; | |
| 6 | ||
| 7 | import jav a.io.ByteA rrayOutput Stream; | |
| 8 | import jav a.security .MessageDi gest; | |
| 9 | ||
| 10 | import gov .va.med.fw .model.Has hSummary; | |
| 11 | ||
| 12 | /** | |
| 13 | * Central utility f or hashing needs. | |
| 14 | * | |
| 15 | * Origina l Author - DN S
|
|
| 16 | * Creatio n Date - O ct 29, 200 9 3:09:41 PM | |
| 17 | */ | |
| 18 | public cla ss HashUti ls { | |
| 19 | pu blic stati c final ch ar[] HEX_C HARS = { ' 0', '1', ' 2', '3', ' 4', '5', ' 6', '7', ' 8', '9', ' a', 'b', ' c', | |
| 20 | 'd', ' e', 'f' }; | |
| 21 | ||
| 22 | pu blic stati c final St ring DEFAU LT_ALGORIT HM = "SHA- 256"; | |
| 23 | ||
| 24 | pu blic stati c HashSumm ary hash(O bject item ToHash, St ring algor ithm) thro ws Excepti on { | |
| 25 | retu rn hash(it emToHash, null, algo rithm); | |
| 26 | } | |
| 27 | ||
| 28 | pu blic stati c HashSumm ary hash(O bject item ToHash) th rows Excep tion { | |
| 29 | retu rn hash(it emToHash, null, DEFA ULT_ALGORI THM); | |
| 30 | } | |
| 31 | ||
| 32 | pu blic stati c HashSumm ary hash(O bject item ToHash, St ring key, String alg orithm) th rows Excep tion{ | |
| 33 | if(i temToHash == null && key == nu ll) | |
| 34 | return null; | |
| 35 | ||
| 36 | // T ODO: if Me ssageDiges t is threa d-safe, co uld share static ins tance | |
| 37 | Mess ageDigest digest = j ava.securi ty.Message Digest.get Instance(a lgorithm); | |
| 38 | ||
| 39 | /*Sy stem.out.p rintln("Ha sh perform ed using M essageDige st [name / version / info]: [" + digest. getProvide r().getNam e() + | |
| 40 | " / " + digest.get Provider() .getVersio n() + " / " + digest .getProvid er().getIn fo() + "]" ); | |
| 41 | */ | |
| 42 | ||
| 43 | int hash = ite mToHash.ha shCode(); | |
| 44 | Byte ArrayOutpu tStream ba os = new B yteArrayOu tputStream (); | |
| 45 | baos .write(has h); | |
| 46 | if ( key != nu ll ) { | |
| 47 | baos.w rite(key.g etBytes()) ; | |
| 48 | } | |
| 49 | dige st.update( baos.toByt eArray()); | |
| 50 | byte [] hashSig = digest. digest(); | |
| 51 | char buf[] = n ew char[ha shSig.leng th * 2]; | |
| 52 | for (int i = 0 , x = 0; i < hashSig .length; i ++) { | |
| 53 | buf[x+ +] = HEX_C HARS[(hash Sig[i] >>> 4) & 0xf] ; | |
| 54 | buf[x+ +] = HEX_C HARS[hashS ig[i] & 0x f]; | |
| 55 | } | |
| 56 | retu rn new Has hSummary(n ew String( buf), dige st); | |
| 57 | } | |
| 58 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.