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_base64.rb,
lib/core_ext/string/to_sha256.rb,
lib/core_ext/string/to_sha512.rb,
lib/core_ext/string/byte_packing.rb
Instance Method Summary collapse
- #packed_bytes ⇒ Object
- #to_base64 ⇒ Object
- #to_md5 ⇒ Object
- #to_sha1 ⇒ Object
- #to_sha256 ⇒ Object
- #to_sha512 ⇒ Object
- #unpack_base64 ⇒ 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_base64 ⇒ Object
4 5 6 |
# File 'lib/core_ext/string/to_base64.rb', line 4 def to_base64 Base64.strict_encode64 self 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 |
#to_sha512 ⇒ Object
2 3 4 |
# File 'lib/core_ext/string/to_sha512.rb', line 2 def to_sha512 Digest::SHA512.hexdigest self end |
#unpack_base64 ⇒ Object
8 9 10 |
# File 'lib/core_ext/string/to_base64.rb', line 8 def unpack_base64 Base64.decode64 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 |