Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. # File: encryption-9.rb
  2. #
  3. require 'digest'
  4.  
  5. module Encryption
  6. module InstanceMethods
  7. def encrypt
  8. self.class.encrypt message_to_encrypt
  9. end
  10. end
  11.  
  12. module ClassMethods
  13. def encrypt(clear_text)
  14. Digest::SHA256.base64digest clear_text
  15. end
  16. end
  17.  
  18. def self.included(base)
  19. reuse_module(base)
  20. end
  21.  
  22. def self.extended(base)
  23. reuse_module(base)
  24. end
  25.  
  26. def self.reuse_module(base)
  27. base.include Encryption::InstanceMethods
  28. base.extend Encryption::ClassMethods
  29. end
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement