Skip to content

Commit 6ec392c

Browse files
author
HD Moore
committed
Add Rex::Text.sha1 and Rex::Text.sha1_raw
1 parent 19920b3 commit 6ec392c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/rex/text.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: binary -*-
22
require 'digest/md5'
3+
require 'digest/sha1'
34
require 'stringio'
45

56
begin
@@ -812,6 +813,20 @@ def self.md5(str)
812813
Digest::MD5.hexdigest(str)
813814
end
814815

816+
#
817+
# Raw SHA1 digest of the supplied string
818+
#
819+
def self.sha1_raw(str)
820+
Digest::SHA1.digest(str)
821+
end
822+
823+
#
824+
# Hexidecimal SHA1 digest of the supplied string
825+
#
826+
def self.sha1(str)
827+
Digest::SHA1.hexdigest(str)
828+
end
829+
815830
#
816831
# Convert hex-encoded characters to literals.
817832
# Example: "AA\\x42CC" becomes "AABCC"

0 commit comments

Comments
 (0)