File: string.rb

package info (click to toggle)
ruby-encryptor 3.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 200 kB
  • sloc: ruby: 450; makefile: 4
file content (24 lines) | stat: -rw-r--r-- 724 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module Encryptor
  # Adds <tt>encrypt</tt> and <tt>decrypt</tt> methods to strings
  module String
    # Returns a new string containing the encrypted version of itself
    def encrypt(options = {})
      Encryptor.encrypt(options.merge(value: self))
    end

    # Replaces the contents of a string with the encrypted version of itself
    def encrypt!(options ={})
      replace encrypt(options)
    end

    # Returns a new string containing the decrypted version of itself
    def decrypt(options = {})
      Encryptor.decrypt(options.merge(value: self))
    end

    # Replaces the contents of a string with the decrypted version of itself
    def decrypt!(options = {})
      replace decrypt(options)
    end
  end
end