Module: Crypt

Defined in:
lib/perpetual/string/crypt.rb

Overview

– This file is part of Perpetual.

Copyright© 2012 Giovanni Capuano <[email protected]>

Perpetual is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Perpetual is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with Perpetual. If not, see <www.gnu.org/licenses/>. ++

Class Method Summary collapse

Class Method Details

.base64_decode(*h) ⇒ Object

Returns the base64 decoded string of one or more hashes that will be joined.



28
29
30
31
# File 'lib/perpetual/string/crypt.rb', line 28

def self.base64_decode(*h)
  require 'base64'
  Base64.decode64 h.join
end

.base64_encode(*s) ⇒ Object Also known as: to_base64

Returns the base64 encoded hash of one or more strings that will be joined.



22
23
24
25
# File 'lib/perpetual/string/crypt.rb', line 22

def self.base64_encode(*s)
  require 'base64'
  Base64.encode64 s.join
end

.md5(*s) ⇒ Object Also known as: to_md5

Returns the MD5 hash of one or more strings that will be joined.



34
35
36
37
# File 'lib/perpetual/string/crypt.rb', line 34

def self.md5(*s)
  require 'digest/md5'
  Digest::MD5.hexdigest s.join
end

.sha1(*s) ⇒ Object Also known as: to_sha1

Returns the SHA1 hash of one or more strings that will be joined.



40
41
42
43
# File 'lib/perpetual/string/crypt.rb', line 40

def self.sha1(*s)
  require 'digest/sha1'
  Digest::SHA1.hexdigest s.join
end