Class: Worklog::Hasher
- Inherits:
-
Object
- Object
- Worklog::Hasher
- Defined in:
- lib/hasher.rb
Overview
Simple hashing utility
Class Method Summary collapse
-
.sha256(input, length = 7) ⇒ String
Generate SHA256 hash for the given input string.
Class Method Details
.sha256(input, length = 7) ⇒ String
Generate SHA256 hash for the given input string
13 14 15 16 17 |
# File 'lib/hasher.rb', line 13 def self.sha256(input, length = 7) raise ArgumentError, 'Length must be between 1 and 64' unless length.between?(1, 64) Digest::SHA256.hexdigest(input)[..(length - 1)] end |