Class: CryptoconditionsRuby::Utils::Base16
- Inherits:
-
Object
- Object
- CryptoconditionsRuby::Utils::Base16
- Defined in:
- lib/cryptoconditions_ruby/utils/base16.rb
Class Method Summary collapse
Class Method Details
.decode(data) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cryptoconditions_ruby/utils/base16.rb', line 14 def self.decode(data) chars = '' ret = '' data.each_char do |c| chars += c if chars.size == 2 ret += chars.to_i(16).chr chars = '' end end ret end |
.encode(data) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/cryptoconditions_ruby/utils/base16.rb', line 4 def self.encode(data) ret = '' data.each_char do |c| ch = c.ord.to_s(16) ch = '0' + ch if ch.size == 1 ret += ch end ret.upcase end |