Sha256: b7339b5bf0028e677f9593188c784da7bce97e6b16436413b5ea50896a4cbbb4
Contents?: true
Size: 1.24 KB
Versions: 13
Compression:
Stored size: 1.24 KB
Contents
# -*- coding: binary -*- module Rex module Text # We are re-opening the module to add these module methods. # Breaking them up this way allows us to maintain a little higher # degree of organisation and make it easier to find what you're looking for # without hanging the underlying calls that we historically rely upon. # @param str [String] Data to checksum # @return [Fixnum] 8-bit checksum def self.checksum8(str) (str.unpack("C*").inject(:+) || 0) % 0x100 end # @param str [String] Little-endian data to checksum # @return [Fixnum] 16-bit checksum def self.checksum16_le(str) (str.unpack("v*").inject(:+) || 0) % 0x10000 end # @param str [String] Big-endian data to checksum # @return [Fixnum] 16-bit checksum def self.checksum16_be(str) (str.unpack("n*").inject(:+) || 0) % 0x10000 end # @param str [String] Little-endian data to checksum # @return [Fixnum] 32-bit checksum def self.checksum32_le(str) (str.unpack("V*").inject(:+) || 0) % 0x100000000 end # @param str [String] Big-endian data to checksum # @return [Fixnum] 32-bit checksum def self.checksum32_be(str) (str.unpack("N*").inject(:+) || 0) % 0x100000000 end end end
Version data entries
13 entries across 13 versions & 1 rubygems