<commit_before>class Crypt
  class ByteStream < String
=begin rdoc
A subclass of String with a single purpose: to provide the ^ (XOR) operator, for encryption purposes.
=end

=begin rdoc
Returned values are still of class Crypt::ByteStream, and are of the same length as the longer value. Note that this means that:
a=Crypt::ByteStream.new("a")
bb=Crypt::ByteStream.new("b")
a^bb^bb

...does not equal "a" but rather "a\000", so this should be used with caution except where you have equal-size strings in mind.
=end
    def ^(string)
        max_length=if(self.length > string.length)
            self.length
        else
            string.length
        end
        my_bytes=self.unpack("C*")
        other_bytes=string.unpack("C*")
        out_bytes=Array.new
        0.upto(max_length-1) do
            |i|
            out_bytes[i]=(my_bytes[i]||0)^(other_bytes[i]||0)
        end
        self.class.new(out_bytes.pack("C*"))
    end
    def +(string)
        my_dwords=self.unpack("N*")
        other_dwords=string.unpack("N*")
        max_length=if(my_dwords.length > other_dwords.length)
            my_dwords.length
        else
            other_dwords.length
        end
        out_dwords=Array.new
        0.upto(max_length-1) do
            |i|
            out_dwords[i]=(my_dwords[i]||0)+(other_dwords[i]||0)&0xffffffff
        end
        self.class.new(out_dwords.pack("N*"))
    end
    Use_getbyte = "".respond_to?(:getbyte)
    def byte_at(position)
      if(Use_getbyte)
        self.getbyte(position)
      else
        self.slice(position)
      end
    end
    @@strict_mode = false
    def self.strict_mode=(new_mode)
      @@strict_mode=new_mode
    end
    def [](anything, whatever=nil)
      if(whatever)
        self.slice(anything, whatever)
      elsif(@@strict_mode)
        raise "Ambiguous, you must use #byte_at instead"
      else
        STDERR.puts "Ambiguous usage of [], please use #byte_at"
      end
    end
  end
end
<commit_msg>Support setting here<commit_after>class Crypt
  class ByteStream < String
=begin rdoc
A subclass of String with a single purpose: to provide the ^ (XOR) operator, for encryption purposes.
=end

=begin rdoc
Returned values are still of class Crypt::ByteStream, and are of the same length as the longer value. Note that this means that:
a=Crypt::ByteStream.new("a")
bb=Crypt::ByteStream.new("b")
a^bb^bb

...does not equal "a" but rather "a\000", so this should be used with caution except where you have equal-size strings in mind.
=end
    def ^(string)
        max_length=if(self.length > string.length)
            self.length
        else
            string.length
        end
        my_bytes=self.unpack("C*")
        other_bytes=string.unpack("C*")
        out_bytes=Array.new
        0.upto(max_length-1) do
            |i|
            out_bytes[i]=(my_bytes[i]||0)^(other_bytes[i]||0)
        end
        self.class.new(out_bytes.pack("C*"))
    end
    def +(string)
        my_dwords=self.unpack("N*")
        other_dwords=string.unpack("N*")
        max_length=if(my_dwords.length > other_dwords.length)
            my_dwords.length
        else
            other_dwords.length
        end
        out_dwords=Array.new
        0.upto(max_length-1) do
            |i|
            out_dwords[i]=(my_dwords[i]||0)+(other_dwords[i]||0)&0xffffffff
        end
        self.class.new(out_dwords.pack("N*"))
    end
    Use_getbyte = "".respond_to?(:getbyte)
    def byte_at(position, new_value=nil)
      if(new_value)
        self.slice(position, 1)=[new_value].pack("C")
      elsif(Use_getbyte)
        self.getbyte(position)
      else
        self.slice(position)
      end
    end
    @@strict_mode = false
    def self.strict_mode=(new_mode)
      @@strict_mode=new_mode
    end
    def [](anything, whatever=nil)
      if(whatever)
        self.slice(anything, whatever)
      elsif(@@strict_mode)
        raise "Ambiguous, you must use #byte_at instead"
      else
        STDERR.puts "Ambiguous usage of [], please use #byte_at"
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.11372064276885044, 'fraction_numerical': 0.006180469715698393, 'mean_word_length': 2.4143459915611816, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1246471', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1334, 'n_words': 310}