Path: blob/master/spec/lib/rex/crypto_spec.rb
19758 views
# -*- coding:binary -*-1require 'spec_helper'23RSpec.describe Rex::Crypto do4describe '.bytes_to_int' do5it 'converts an empty byte correctly' do6expect(subject.bytes_to_int("".b)).to eq(0)7end89it 'converts a single null byte correctly' do10expect(subject.bytes_to_int("\x00".b)).to eq(0)11end1213it 'converts a single non-null byte correctly' do14expect(subject.bytes_to_int("\x01".b)).to eq(1)15end1617it 'converts multiple bytes correctly' do18expect(subject.bytes_to_int("\x01\x02\x03\x04".b)).to eq(16909060)19end20end2122describe '.int_to_bytes' do23it 'converts 0 to an empty byte' do24expect(subject.int_to_bytes(0)).to eq("".b)25end2627it 'converts to bytes correctly' do28expect(subject.int_to_bytes(1)).to eq("\x01".b)29expect(subject.int_to_bytes(16909060)).to eq("\x01\x02\x03\x04".b)30end31end32end3334