-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
require 'openssl' | ||
|
||
module FFaker | ||
module Crypto | ||
extend ModuleUtils | ||
extend self | ||
|
||
def sha256 | ||
OpenSSL::Digest::SHA256.hexdigest(Lorem.characters) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'helper' | ||
|
||
class TestCrypto < Test::Unit::TestCase | ||
include DeterministicHelper | ||
|
||
assert_methods_are_deterministic(FFaker::Crypto, :sha256) | ||
|
||
def test_sha256 | ||
assert FFaker::Crypto.sha256.is_a?(String) | ||
assert FFaker::Crypto.sha256.length == 64 | ||
assert_match(/\A[a-z\d]{64}\z/, FFaker::Crypto.sha256) | ||
end | ||
end |