From 540e992276998af6cd6fcac0f9f317c9e3e95478 Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Fri, 6 Mar 2020 13:47:25 -0300 Subject: [PATCH] Replace usages of CRC32 in std-lib --- src/gzip/gzip.cr | 2 +- src/gzip/reader.cr | 6 +++--- src/gzip/writer.cr | 4 ++-- src/zip/zip.cr | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gzip/gzip.cr b/src/gzip/gzip.cr index 6441f8ded337..25e6bf29257c 100644 --- a/src/gzip/gzip.cr +++ b/src/gzip/gzip.cr @@ -1,5 +1,5 @@ require "flate" -require "crc32" +require "digest/crc32" # The Gzip module contains readers and writers of gzip format compressed # data, as specified in [RFC 1952](https://www.ietf.org/rfc/rfc1952.txt). diff --git a/src/gzip/reader.cr b/src/gzip/reader.cr index a3334185871d..c5084b989a40 100644 --- a/src/gzip/reader.cr +++ b/src/gzip/reader.cr @@ -43,7 +43,7 @@ class Gzip::Reader < IO # Creates a new reader from the given *io*. def initialize(@io : IO, @sync_close = false) # CRC32 of written data - @crc32 = CRC32.initial + @crc32 = Digest::CRC32.initial # Total size of the original (uncompressed) input data modulo 2^32. @isize = 0_u32 @@ -101,7 +101,7 @@ class Gzip::Reader < IO end # Reset checksum and total size for next entry - @crc32 = CRC32.initial + @crc32 = Digest::CRC32.initial @isize = 0_u32 # Check if another header with data comes @@ -115,7 +115,7 @@ class Gzip::Reader < IO end else # Update CRC32 and total data size - @crc32 = CRC32.update(slice[0, read_bytes], @crc32) + @crc32 = Digest::CRC32.update(slice[0, read_bytes], @crc32) # Using wrapping addition here because isize is only 32 bits wide but # uncompressed data size can be bigger. diff --git a/src/gzip/writer.cr b/src/gzip/writer.cr index c1f90193d92c..c25b88b79e83 100644 --- a/src/gzip/writer.cr +++ b/src/gzip/writer.cr @@ -37,7 +37,7 @@ class Gzip::Writer < IO # Creates a new writer to the given *io*. def initialize(@io : IO, @level = Gzip::DEFAULT_COMPRESSION, @sync_close = false) # CRC32 of written data - @crc32 = CRC32.initial + @crc32 = Digest::CRC32.initial # Total size of the original (uncompressed) input data modulo 2^32. @isize = 0 @@ -77,7 +77,7 @@ class Gzip::Writer < IO flate_io.write(slice) # Update CRC32 and total data size - @crc32 = CRC32.update(slice, @crc32) + @crc32 = Digest::CRC32.update(slice, @crc32) # Using wrapping addition here because isize is only 32 bits wide but # uncompressed data size can be bigger. diff --git a/src/zip/zip.cr b/src/zip/zip.cr index e7938224f25d..4e79ea8974e9 100644 --- a/src/zip/zip.cr +++ b/src/zip/zip.cr @@ -1,5 +1,5 @@ require "flate" -require "crc32" +require "digest/crc32" require "./*" # The Zip module contains readers and writers of the zip