1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-12 11:52:01 +01:00

md5 and base64

git-svn-id: file:///home/svn/incoming/trunk@2922 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Matt Miller 2005-09-30 06:48:52 +00:00
parent d22d0ee851
commit aeb6e66e67
2 changed files with 41 additions and 0 deletions

View File

@ -1,3 +1,6 @@
require 'base64'
require 'md5'
module Rex
###
@ -153,6 +156,40 @@ module Text
return output
end
##
#
# Transforms
#
##
#
# Base64 encoder
#
def self.encode_base64(str)
Base64.encode64(str)
end
#
# Base64 decoder
#
def self.decode_base64(str)
Base64.decode64(str)
end
#
# Raw MD5 digest of the supplied string
#
def self.md5_raw(str)
MD5.digest(str)
end
#
# Hexidecimal MD5 digest of the supplied string
#
def self.md5(str)
MD5.hexdigest(str)
end
##
#
# Generators

View File

@ -28,4 +28,8 @@ class Rex::Text::UnitTest < Test::Unit::TestCase
assert_equal("this is a \ntest of \nthe word \nwrap \nfeatures\n", Rex::Text.wordwrap(txt, 0, 10))
end
def test_transforms
assert_equal("acbd18db4cc2f85cedef654fccc4a4d8", Rex::Text.md5('foo'))
end
end