File tree Expand file tree Collapse file tree 8 files changed +29
-25
lines changed
src/main/java/com/reandroid Expand file tree Collapse file tree 8 files changed +29
-25
lines changed Original file line number Diff line number Diff line change 1515 */
1616package com .reandroid .apk ;
1717
18+ import com .reandroid .utils .CRCDigest ;
19+
1820import java .io .IOException ;
1921import java .io .OutputStream ;
20- import java .util .zip .CRC32 ;
2122
23+ @ Deprecated
2224public class CrcOutputStream extends OutputStream {
23- private final CRC32 crc ;
25+ private final CRCDigest crc ;
2426 private long length ;
2527 private long mCheckSum ;
2628 public CrcOutputStream () {
2729 super ();
28- this .crc = new CRC32 ();
30+ this .crc = new CRCDigest ();
2931 }
3032 public long getLength (){
3133 return length ;
Original file line number Diff line number Diff line change 2121import com .reandroid .arsc .chunk .TableBlock ;
2222import com .reandroid .json .JSONException ;
2323import com .reandroid .json .JSONObject ;
24+ import com .reandroid .utils .CRCDigest ;
2425
2526import java .io .*;
2627
@@ -58,9 +59,9 @@ public long getLength() throws IOException{
5859 }
5960 @ Override
6061 public long getCrc () throws IOException {
61- CrcOutputStream outputStream = new CrcOutputStream ();
62+ CRCDigest outputStream = new CRCDigest ();
6263 this .write (outputStream );
63- return outputStream .getCrcValue ();
64+ return outputStream .getValue ();
6465 }
6566 public TableBlock getTableBlock () throws IOException {
6667 if (mCache != null ){
Original file line number Diff line number Diff line change 1717
1818import com .reandroid .archive .BlockInputSource ;
1919import com .reandroid .arsc .chunk .TableBlock ;
20+ import com .reandroid .utils .CRCDigest ;
2021
2122import java .io .*;
2223
@@ -54,9 +55,9 @@ public long getLength() throws IOException{
5455 }
5556 @ Override
5657 public long getCrc () throws IOException {
57- CrcOutputStream outputStream = new CrcOutputStream ();
58+ CRCDigest outputStream = new CRCDigest ();
5859 this .write (outputStream );
59- return outputStream .getCrcValue ();
60+ return outputStream .getValue ();
6061 }
6162 public TableBlock getTableBlock () throws IOException {
6263 if (mCache !=null ){
Original file line number Diff line number Diff line change 11package com .reandroid .apk .xmlencoder ;
22
33import com .reandroid .apk .APKLogger ;
4- import com .reandroid .apk .CrcOutputStream ;
54import com .reandroid .archive .ByteInputSource ;
65import com .reandroid .arsc .chunk .PackageBlock ;
76import com .reandroid .arsc .chunk .xml .ResXmlDocument ;
7+ import com .reandroid .utils .CRCDigest ;
88import com .reandroid .utils .io .IOUtil ;
99import com .reandroid .xml .source .XMLParserSource ;
1010import org .xmlpull .v1 .XmlPullParser ;
1111import org .xmlpull .v1 .XmlPullParserException ;
1212
1313import java .io .IOException ;
1414import java .io .OutputStream ;
15- import java .util .zip .CRC32 ;
1615
1716public class XMLEncodeSource extends ByteInputSource {
1817 private final PackageBlock packageBlock ;
@@ -31,7 +30,7 @@ public long getLength() throws IOException {
3130 }
3231 @ Override
3332 public long getCrc () throws IOException {
34- CRC32 crc32 = new CRC32 ();
33+ CRCDigest crc32 = new CRCDigest ();
3534 byte [] bytes = getArray ();
3635 crc32 .update (bytes , 0 , bytes .length );
3736 return crc32 .getValue ();
Original file line number Diff line number Diff line change 1515 */
1616package com .reandroid .archive ;
1717
18- import com .reandroid .apk .CrcOutputStream ;
1918import com .reandroid .arsc .base .Block ;
2019import com .reandroid .arsc .base .BlockRefresh ;
20+ import com .reandroid .utils .CRCDigest ;
2121
2222import java .io .IOException ;
2323import java .io .OutputStream ;
@@ -51,9 +51,9 @@ public long getLength() throws IOException{
5151 @ Override
5252 public long getCrc () throws IOException {
5353 Block block = getBlock ();
54- CrcOutputStream outputStream = new CrcOutputStream ();
54+ CRCDigest outputStream = new CRCDigest ();
5555 block .writeBytes (outputStream );
56- return outputStream .getCrcValue ();
56+ return outputStream .getValue ();
5757 }
5858 @ Override
5959 public long write (OutputStream outputStream ) throws IOException {
Original file line number Diff line number Diff line change 1717
1818import com .reandroid .arsc .chunk .TableBlock ;
1919import com .reandroid .arsc .chunk .xml .AndroidManifestBlock ;
20+ import com .reandroid .utils .CRCDigest ;
2021import com .reandroid .utils .CompareUtil ;
2122import com .reandroid .utils .StringsUtil ;
2223import com .reandroid .utils .io .FileUtil ;
2324
2425import java .io .*;
2526import java .util .Comparator ;
26- import java .util .zip .CRC32 ;
2727
2828public abstract class InputSource {
2929 private final String name ;
@@ -174,7 +174,7 @@ public String toString(){
174174 private void calculateCrc () throws IOException {
175175 InputStream inputStream =openStream ();
176176 long length =0 ;
177- CRC32 crc = new CRC32 ();
177+ CRCDigest crc = new CRCDigest ();
178178 int bytesRead ;
179179 byte [] buffer = new byte [1024 *64 ];
180180 while ((bytesRead = inputStream .read (buffer )) != -1 ) {
Original file line number Diff line number Diff line change 1515 */
1616package com .reandroid .archive .io ;
1717
18+ import com .reandroid .utils .CRCDigest ;
1819import com .reandroid .utils .HexUtil ;
1920
2021import java .io .IOException ;
2122import java .io .InputStream ;
22- import java .util .zip .CRC32 ;
2323
2424public class CountingInputStream <T extends InputStream > extends InputStream {
2525 private final T inputStream ;
26- private final CRC32 crc ;
26+ private final CRCDigest crc ;
2727 private long size ;
2828 private long mCheckSum ;
2929 private boolean mFinished ;
3030 public CountingInputStream (T inputStream , boolean disableCrc ){
3131 this .inputStream = inputStream ;
32- CRC32 crc32 ;
32+ CRCDigest crc32 ;
3333 if (disableCrc ){
3434 crc32 = null ;
3535 }else {
36- crc32 = new CRC32 ();
36+ crc32 = new CRCDigest ();
3737 }
3838 this .crc = crc32 ;
3939 }
Original file line number Diff line number Diff line change 1515 */
1616package com .reandroid .archive .io ;
1717
18+ import com .reandroid .utils .CRCDigest ;
19+
1820import java .io .IOException ;
1921import java .io .InputStream ;
2022import java .io .OutputStream ;
21- import java .util .zip .CRC32 ;
2223
2324public class CountingOutputStream <T extends OutputStream > extends OutputStream {
2425 private final T outputStream ;
25- private CRC32 crc ;
26+ private CRCDigest crc ;
2627 private long size ;
2728 private boolean mClosed ;
2829 public CountingOutputStream (T outputStream , boolean disableCrc ){
2930 this .outputStream = outputStream ;
30- CRC32 crc32 ;
31+ CRCDigest crc32 ;
3132 if (disableCrc ){
3233 crc32 = null ;
3334 }else {
34- crc32 = new CRC32 ();
35+ crc32 = new CRCDigest ();
3536 }
3637 this .crc = crc32 ;
3738 }
@@ -42,15 +43,15 @@ public CountingOutputStream(T outputStream){
4243 public void disableCrc (boolean disableCrc ) {
4344 if (!disableCrc ){
4445 if (crc == null ){
45- this .crc = new CRC32 ();
46+ this .crc = new CRCDigest ();
4647 }
4748 }else {
4849 this .crc = null ;
4950 }
5051 }
5152
5253 public void reset (){
53- this .crc = new CRC32 ();
54+ this .crc = new CRCDigest ();
5455 this .size = 0L ;
5556 }
5657 public T getOutputStream () {
You can’t perform that action at this time.
0 commit comments