Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_ext/string/to_md5.rb,
lib/core_ext/string/to_sha1.rb,
lib/core_ext/string/to_sha256.rb,
lib/core_ext/string/byte_packing.rb
Instance Method Summary collapse
- #packed_bytes ⇒ Object
- #to_md5 ⇒ Object
- #to_sha1 ⇒ Object
- #to_sha256 ⇒ Object
- #unpacked_bytes ⇒ Object
Instance Method Details
#packed_bytes ⇒ Object
2 3 4 |
# File 'lib/core_ext/string/byte_packing.rb', line 2 def packed_bytes [self].pack('H*') end |
#to_md5 ⇒ Object
2 3 4 |
# File 'lib/core_ext/string/to_md5.rb', line 2 def to_md5 Digest::MD5.hexdigest self end |
#to_sha1 ⇒ Object
2 3 4 |
# File 'lib/core_ext/string/to_sha1.rb', line 2 def to_sha1 Digest::SHA1.hexdigest self end |
#to_sha256 ⇒ Object
2 3 4 |
# File 'lib/core_ext/string/to_sha256.rb', line 2 def to_sha256 Digest::SHA256.hexdigest self end |
#unpacked_bytes ⇒ Object
6 7 8 |
# File 'lib/core_ext/string/byte_packing.rb', line 6 def unpacked_bytes self.unpack('H*').first end |