class Analyzers::Utils::AsciiLanguageDetector

Constants

ASCII_BASE_RANGE
ASCII_BLACKLIST
ASCII_CHARACTERS
ASCII_WHITELIST

Public Instance Methods

ascii_lingual?(buf) click to toggle source
# File lib/crypto-toolbox/analyzers/utils/ascii_language_detector.rb, line 46
def ascii_lingual?(buf)
  ascii_lingual_bytes?(buf.bytes)
end
ascii_lingual_byte?(byte) click to toggle source
# File lib/crypto-toolbox/analyzers/utils/ascii_language_detector.rb, line 33
def ascii_lingual_byte?(byte)
  # check how fast bsearch is, if range.cover is no longer needed we can nicely add 10 to the array
  (ascii_base_range.cover?(byte) && !ascii_blacklist.include?(byte)) || ( ascii_whitelist.bsearch{|i| i == byte} )
end
ascii_lingual_bytes() click to toggle source
# File lib/crypto-toolbox/analyzers/utils/ascii_language_detector.rb, line 50
def ascii_lingual_bytes
  ascii_whitelist.to_ary
end
ascii_lingual_bytes?(bytes) click to toggle source
# File lib/crypto-toolbox/analyzers/utils/ascii_language_detector.rb, line 38
def ascii_lingual_bytes?(bytes)
  bytes.all?{|b| ascii_lingual_byte?(b) }
end
ascii_lingual_chars() click to toggle source
# File lib/crypto-toolbox/analyzers/utils/ascii_language_detector.rb, line 42
def ascii_lingual_chars
  ASCII_CHARACTERS
end

Private Instance Methods

ascii_base_range() click to toggle source

building up the range is too slow, thus we cache

# File lib/crypto-toolbox/analyzers/utils/ascii_language_detector.rb, line 57
def ascii_base_range
  ASCII_BASE_RANGE
end
ascii_blacklist() click to toggle source
# File lib/crypto-toolbox/analyzers/utils/ascii_language_detector.rb, line 65
def ascii_blacklist
  ASCII_BLACKLIST
end
ascii_whitelist() click to toggle source
# File lib/crypto-toolbox/analyzers/utils/ascii_language_detector.rb, line 61
def ascii_whitelist
  ASCII_WHITELIST
end