Class: PlainBufferCrc8

Inherits:
Object
  • Object
show all
Defined in:
lib/tablestore/plain_buffer_crc8.rb

Class Method Summary collapse

Class Method Details

.crc_int32(crc, byte) ⇒ Object



13
14
15
# File 'lib/tablestore/plain_buffer_crc8.rb', line 13

def crc_int32(crc, byte)
  Digest::CRC8Auto.new.crc8(crc, [byte].pack('i')).checksum
end

.crc_int64(crc, byte) ⇒ Object



17
18
19
# File 'lib/tablestore/plain_buffer_crc8.rb', line 17

def crc_int64(crc, byte)
  Digest::CRC8Auto.new.crc8(crc, [byte].pack('q')).checksum
end

.crc_int8(crc, byte) ⇒ Object



9
10
11
# File 'lib/tablestore/plain_buffer_crc8.rb', line 9

def crc_int8(crc, byte)
  Digest::CRC8Auto.new.crc8(crc, [byte].pack('C*')).checksum
end

.crc_string(crc, bytes) ⇒ Object



5
6
7
# File 'lib/tablestore/plain_buffer_crc8.rb', line 5

def crc_string(crc, bytes)
  Digest::CRC8Auto.new.crc8(crc, bytes.to_s).checksum
end