module OpenPGP
Constants
- CRC24_INIT
- CRC24_POLY
Public Class Methods
bitlength(data)
click to toggle source
Returns the bit length of a multiprecision integer (MPI).
@param [String] data @return [Integer] @see tools.ietf.org/html/rfc4880#section-3.2
# File lib/openpgp/util.rb, line 66 def self.bitlength(data) data.empty? ? 0 : (data.size - 1) * 8 + (Math.log(data[0].ord) / Math.log(2)).floor + 1 end
crc24(data)
click to toggle source
@param [String] data @return [Integer] @see tools.ietf.org/html/rfc4880#section-6 @see tools.ietf.org/html/rfc4880#section-6.1
# File lib/openpgp/util.rb, line 48 def self.crc24(data) crc = CRC24_INIT data.each_byte do |octet| crc ^= octet << 16 8.times do crc <<= 1 crc ^= CRC24_POLY if (crc & 0x01000000).nonzero? end end crc &= 0x00ffffff end
dearmor(text, marker = nil, options = {})
click to toggle source
Alias for {OpenPGP::Armor.decode}.
# File lib/openpgp/util.rb, line 10 def self.dearmor(text, marker = nil, options = {}) Armor.decode(text, marker, options) end
decrypt(data, options = {})
click to toggle source
Alias for {OpenPGP::Message.decrypt}.
# File lib/openpgp/util.rb, line 22 def self.decrypt(data, options = {}) raise NotImplementedError # TODO end
enarmor(data, marker = :message, options = {})
click to toggle source
Alias for {OpenPGP::Armor.encode}.
# File lib/openpgp/util.rb, line 4 def self.enarmor(data, marker = :message, options = {}) Armor.encode(data, marker, options) end
encrypt(data, options = {})
click to toggle source
Alias for {OpenPGP::Message.encrypt}.
# File lib/openpgp/util.rb, line 16 def self.encrypt(data, options = {}) (msg = Message.encrypt(data, options)) ? msg.to_s : nil end
sign()
click to toggle source
Alias for {OpenPGP::Message.sign}.
# File lib/openpgp/util.rb, line 28 def self.sign raise NotImplementedError # TODO end
verify()
click to toggle source
Alias for {OpenPGP::Message.verify}.
# File lib/openpgp/util.rb, line 34 def self.verify raise NotImplementedError # TODO end