wikk_aes_256 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/History.txt +26 -0
- data/README.md +4 -4
- data/Rakefile +13 -15
- data/lib/wikk_aes_256.rb +127 -103
- metadata +9 -10
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: 8f641efe6dea090212b60597da2f3dbe5b3ac805fccc7183eaa7dca9f4156914
         | 
| 4 | 
            +
              data.tar.gz: 481ca75fda9a56e0929315b71e84e958d8430dd9d007a3cba78c8c180aab9eb3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 677eb9a8e8e2d251f49cf31a15105993cc57a012b5fc2b50b2d16f94f862f839d3747623a050bda5f687c432abaf7c7dd789ce82a50ce8ab340abb11b76bec63
         | 
| 7 | 
            +
              data.tar.gz: d97f2d804f79b700cc42957720291b43a040bdf9d9044c18455b1a1e4f0bab29ae9376ade09f4a2b6a830395d077884699acf9cd57bfd2e21b01a7253304313b
         | 
    
        data/History.txt
    CHANGED
    
    | @@ -1,3 +1,29 @@ | |
| 1 | 
            +
            robertburrowes	Sun Jun 5 18:18:15 2022 +1200
         | 
| 2 | 
            +
            	left out require stringio
         | 
| 3 | 
            +
            robertburrowes	Sun Oct 25 22:11:06 2020 +1300
         | 
| 4 | 
            +
            	Tidy up yard doc comments
         | 
| 5 | 
            +
            robertburrowes	Sun Oct 25 17:45:35 2020 +1300
         | 
| 6 | 
            +
            	Chdir to cd as Mac doesn't look to have chdir in sh
         | 
| 7 | 
            +
            robertburrowes	Sun Oct 25 13:51:16 2020 +1300
         | 
| 8 | 
            +
            	New hoe layout
         | 
| 9 | 
            +
            robertburrowes	Sun Oct 25 13:50:46 2020 +1300
         | 
| 10 | 
            +
            	formatting
         | 
| 11 | 
            +
            robertburrowes	Sun Oct 25 13:50:30 2020 +1300
         | 
| 12 | 
            +
            	now including this in repo
         | 
| 13 | 
            +
            robertburrowes	Sun Oct 25 13:50:02 2020 +1300
         | 
| 14 | 
            +
            	Move dev shell scripts into sbin
         | 
| 15 | 
            +
            robertburrowes	Tue Apr 14 21:21:06 2020 +1200
         | 
| 16 | 
            +
            	moved test data to its own dir
         | 
| 17 | 
            +
            robertburrowes	Tue Apr 14 14:32:08 2020 +1200
         | 
| 18 | 
            +
            	mv test data to test/data
         | 
| 19 | 
            +
            robertburrowes	Mon Apr 13 22:55:45 2020 +1200
         | 
| 20 | 
            +
            	Add __dir__ path to access testfile
         | 
| 21 | 
            +
            robertburrowes	Tue Apr 10 11:53:52 2018 +1200
         | 
| 22 | 
            +
            	Inc Version
         | 
| 23 | 
            +
            robertburrowes	Tue Apr 10 11:53:43 2018 +1200
         | 
| 24 | 
            +
            	Inc version
         | 
| 25 | 
            +
            robertburrowes	Tue Apr 10 11:53:33 2018 +1200
         | 
| 26 | 
            +
            	Inc version
         | 
| 1 27 | 
             
            robertburrowes	Tue Apr 10 11:50:22 2018 +1200
         | 
| 2 28 | 
             
            	OpenSSL::Cipher::Cipher.new deprecated in favour of OpenSSL::Cipher.new
         | 
| 3 29 | 
             
            robertburrowes	Fri Jun 24 19:56:31 2016 +1200
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,8 +1,8 @@ | |
| 1 | 
            -
            #  | 
| 1 | 
            +
            # wikk_aes_256
         | 
| 2 2 |  | 
| 3 | 
            -
            *  | 
| 4 | 
            -
            * Source https://github.com/wikarekare/ | 
| 5 | 
            -
            * Gem https://rubygems.org/gems/ | 
| 3 | 
            +
            * Docs :: https://wikarekare.github.io/wikk_aes_256/
         | 
| 4 | 
            +
            * Source :: https://github.com/wikarekare/wikk_aes_256
         | 
| 5 | 
            +
            * Gem :: https://rubygems.org/gems/wikk_aes_256
         | 
| 6 6 |  | 
| 7 7 | 
             
            ## DESCRIPTION:
         | 
| 8 8 |  | 
    
        data/Rakefile
    CHANGED
    
    | @@ -1,27 +1,25 @@ | |
| 1 1 | 
             
            # -*- ruby -*-
         | 
| 2 | 
            -
             | 
| 3 2 | 
             
            require 'rubygems'
         | 
| 4 3 | 
             
            require 'hoe'
         | 
| 5 4 | 
             
            Hoe.plugin :yard
         | 
| 6 5 |  | 
| 7 | 
            -
            Hoe.spec 'wikk_aes_256' do | 
| 8 | 
            -
              self.readme_file =  | 
| 9 | 
            -
              self.developer(  | 
| 6 | 
            +
            Hoe.spec 'wikk_aes_256' do
         | 
| 7 | 
            +
              self.readme_file = 'README.md'
         | 
| 8 | 
            +
              self.developer( 'Rob Burrowes', 'r.burrowes@auckland.ac.nz')
         | 
| 10 9 | 
             
              remote_rdoc_dir = '' # Release to root
         | 
| 11 | 
            -
             | 
| 10 | 
            +
             | 
| 12 11 | 
             
              self.yard_title = 'wikk_aes_256'
         | 
| 13 | 
            -
              self.yard_options = ['--markup', 'markdown', '--protected']
         | 
| 12 | 
            +
              self.yard_options = [ '--markup', 'markdown', '--protected' ]
         | 
| 14 13 | 
             
            end
         | 
| 15 14 |  | 
| 15 | 
            +
            # Validate manfest.txt
         | 
| 16 | 
            +
            # rake check_manifest
         | 
| 16 17 |  | 
| 17 | 
            -
            # | 
| 18 | 
            -
            #rake  | 
| 19 | 
            -
             | 
| 20 | 
            -
            #Local checking. Creates pkg/
         | 
| 21 | 
            -
            #rake gem
         | 
| 18 | 
            +
            # Local checking. Creates pkg/
         | 
| 19 | 
            +
            # rake gem
         | 
| 22 20 |  | 
| 23 | 
            -
            #create doc/
         | 
| 24 | 
            -
            #rake docs | 
| 21 | 
            +
            # create doc/
         | 
| 22 | 
            +
            # rake docs
         | 
| 25 23 |  | 
| 26 | 
            -
            #Copy up to rubygem.org
         | 
| 27 | 
            -
            #rake release VERSION=1.0.1
         | 
| 24 | 
            +
            # Copy up to rubygem.org
         | 
| 25 | 
            +
            # rake release VERSION=1.0.1
         | 
    
        data/lib/wikk_aes_256.rb
    CHANGED
    
    | @@ -1,179 +1,203 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 1 | 
            +
            require 'openssl'
         | 
| 2 | 
            +
            require 'digest/sha2'
         | 
| 3 | 
            +
            require 'base64'
         | 
| 4 | 
            +
            require 'stringio'
         | 
| 5 5 |  | 
| 6 | 
            -
             | 
| 6 | 
            +
            # Stay in our own namespace
         | 
| 7 | 
            +
            module WIKK
         | 
| 8 | 
            +
              # Provides AES 256 Encryption, as well as generation of keys and initial vectors, which could be used in other places.
         | 
| 9 | 
            +
              #
         | 
| 7 10 | 
             
              # @attr_reader [String] plain_text the decrypted text
         | 
| 8 11 | 
             
              # @attr_reader [String] cipher_text the encrypted text
         | 
| 9 12 | 
             
              class AES_256
         | 
| 10 | 
            -
                VERSION =  | 
| 11 | 
            -
                AES_256_CBC =  | 
| 12 | 
            -
             | 
| 13 | 
            +
                VERSION = '0.1.7'
         | 
| 14 | 
            +
                AES_256_CBC = 'AES-256-CBC'
         | 
| 15 | 
            +
             | 
| 13 16 | 
             
                attr_reader :plain_text, :cipher_text
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                #Initialize
         | 
| 16 | 
            -
                # | 
| 17 | 
            +
             | 
| 18 | 
            +
                # Initialize
         | 
| 19 | 
            +
                #
         | 
| 20 | 
            +
                # @param key_string [String] optional base64 key to be used in encryption or decryption.
         | 
| 17 21 | 
             
                #    if nil, then key and iv are generated automatically. Recover the key with key_to_s(), or key_iv_to_s()
         | 
| 18 | 
            -
                # | 
| 22 | 
            +
                # @param iv_string [String ] optional base64 iv (initial vector) to be used in the encryption or decryption
         | 
| 19 23 | 
             
                #    Overwritten by auto generated iv, if key_string is nil. Recover with iv_to_str() or key_iv_to_s().
         | 
| 20 24 | 
             
                def initialize(key_string = nil, iv_string = nil)
         | 
| 21 | 
            -
                  if key_string | 
| 25 | 
            +
                  if key_string.nil?
         | 
| 22 26 | 
             
                    gen_key
         | 
| 23 27 | 
             
                  else
         | 
| 24 28 | 
             
                    str_to_key(key_string)
         | 
| 25 29 | 
             
                  end
         | 
| 26 30 |  | 
| 27 | 
            -
                  if iv_string | 
| 31 | 
            +
                  if iv_string.nil?
         | 
| 28 32 | 
             
                    gen_iv
         | 
| 29 33 | 
             
                  else
         | 
| 30 34 | 
             
                    str_to_iv(iv_string)
         | 
| 31 35 | 
             
                  end
         | 
| 32 36 | 
             
                end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                #Generates a new key using Digest SHA256 in @key.
         | 
| 35 | 
            -
                # | 
| 36 | 
            -
             | 
| 37 | 
            +
             | 
| 38 | 
            +
                # Generates a new key using Digest SHA256 in @key.
         | 
| 39 | 
            +
                #
         | 
| 40 | 
            +
                # @return [String] Binary string, @key
         | 
| 41 | 
            +
                def gen_key
         | 
| 37 42 | 
             
                  digest = Digest::SHA256.new
         | 
| 38 | 
            -
                  digest.update( | 
| 43 | 
            +
                  digest.update('symetric key')
         | 
| 39 44 | 
             
                  return (@key = digest.digest)
         | 
| 40 45 | 
             
                end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                # | 
| 46 | 
            +
             | 
| 47 | 
            +
                # Convert key to a base64 string
         | 
| 48 | 
            +
                #
         | 
| 49 | 
            +
                # @return [String] base64 version of @key
         | 
| 43 50 | 
             
                def key_to_s
         | 
| 44 | 
            -
                  return [@key].pack('m').chomp
         | 
| 51 | 
            +
                  return [ @key ].pack('m').chomp
         | 
| 45 52 | 
             
                end
         | 
| 46 53 |  | 
| 47 | 
            -
                # | 
| 54 | 
            +
                # Convert a base64 string into a key
         | 
| 55 | 
            +
                #
         | 
| 56 | 
            +
                # @param [String] converts base64 version of key into AES_256_CBC Symetric Key.
         | 
| 57 | 
            +
                # @return [String] Binary string, @key
         | 
| 48 58 | 
             
                def str_to_key(base64_keystring)
         | 
| 49 | 
            -
                  return( @key = base64_keystring. | 
| 59 | 
            +
                  return( @key = base64_keystring.unpack1('m') )
         | 
| 50 60 | 
             
                end
         | 
| 51 61 |  | 
| 52 | 
            -
                #Generate random AES_256_CBC initialization vector.
         | 
| 53 | 
            -
                # | 
| 62 | 
            +
                # Generate random AES_256_CBC initialization vector.
         | 
| 63 | 
            +
                #
         | 
| 64 | 
            +
                # @return [String] Binary initialization vector @iv
         | 
| 54 65 | 
             
                def gen_iv
         | 
| 55 66 | 
             
                  return (@iv = OpenSSL::Cipher.new(AES_256_CBC).random_iv)
         | 
| 56 | 
            -
                end | 
| 67 | 
            +
                end
         | 
| 57 68 |  | 
| 58 | 
            -
                # | 
| 69 | 
            +
                # Convert initialization vector to base64 string
         | 
| 70 | 
            +
                #
         | 
| 71 | 
            +
                # @return [String] return Base64 version of initialization vector @iv
         | 
| 59 72 | 
             
                def iv_to_s
         | 
| 60 | 
            -
                  return | 
| 73 | 
            +
                  return [ @iv ].pack('m').chomp
         | 
| 61 74 | 
             
                end
         | 
| 62 | 
            -
             | 
| 63 | 
            -
                # | 
| 64 | 
            -
                # | 
| 75 | 
            +
             | 
| 76 | 
            +
                # Convert base64 string into an initialization vector
         | 
| 77 | 
            +
                #
         | 
| 78 | 
            +
                # @param [String] turns base64 version of iv into AES_256_CBC initialization vector.
         | 
| 79 | 
            +
                # @return [Array] AES_256_CBC initialization vector @iv.
         | 
| 65 80 | 
             
                def str_to_iv(base64_iv_string)
         | 
| 66 | 
            -
                  return (@iv = base64_iv_string. | 
| 81 | 
            +
                  return (@iv = base64_iv_string.unpack1('m'))
         | 
| 67 82 | 
             
                end
         | 
| 68 83 |  | 
| 69 | 
            -
                # | 
| 70 | 
            -
                # | 
| 84 | 
            +
                # Convert key and the initialization vector into base64 strings
         | 
| 85 | 
            +
                #
         | 
| 86 | 
            +
                # @return [String,String] base64 version of @key;
         | 
| 87 | 
            +
                #                         Base64 version of initialization vector @iv
         | 
| 71 88 | 
             
                def key_iv_to_s
         | 
| 72 89 | 
             
                  return key_to_s, iv_to_s
         | 
| 73 90 | 
             
                end
         | 
| 74 | 
            -
             | 
| 75 | 
            -
                #Encrypts source using AES 256 CBC, using @key and @iv
         | 
| 76 | 
            -
                # | 
| 77 | 
            -
                # | 
| 91 | 
            +
             | 
| 92 | 
            +
                # Encrypts source using AES 256 CBC, using @key and @iv
         | 
| 93 | 
            +
                #
         | 
| 94 | 
            +
                # @param unencrypted_source [String|File]
         | 
| 95 | 
            +
                # @return [String] Binary string representing encrypted source
         | 
| 78 96 | 
             
                def encrypt(unencrypted_source)
         | 
| 79 | 
            -
                  unencrypted_source = StringIO.new(unencrypted_source) if | 
| 97 | 
            +
                  unencrypted_source = StringIO.new(unencrypted_source) if unencrypted_source.instance_of?(String)
         | 
| 80 98 | 
             
                  aes = OpenSSL::Cipher.new(AES_256_CBC)
         | 
| 81 99 | 
             
                  aes.encrypt
         | 
| 82 100 | 
             
                  aes.key = @key
         | 
| 83 101 | 
             
                  aes.iv = @iv
         | 
| 84 | 
            -
                  @cipher_text =  | 
| 102 | 
            +
                  @cipher_text = ''
         | 
| 85 103 | 
             
                  while (s = unencrypted_source.read(4096)) != nil do @cipher_text << aes.update(s); end
         | 
| 86 104 | 
             
                  @cipher_text << aes.final
         | 
| 87 105 | 
             
                end
         | 
| 88 | 
            -
             | 
| 89 | 
            -
                #Converts encrypted source String, @cipher_text, into Base64 String
         | 
| 90 | 
            -
                # | 
| 91 | 
            -
                # | 
| 106 | 
            +
             | 
| 107 | 
            +
                # Converts encrypted source String, @cipher_text, into Base64 String
         | 
| 108 | 
            +
                #
         | 
| 109 | 
            +
                # @param unencrypted_source [String|File] If present, then this source is encrypted, otherwise assumes already encrypted.
         | 
| 110 | 
            +
                # @return [String] Base64 string representing encrypted source
         | 
| 92 111 | 
             
                def cipher_to_s(unencrypted_source = nil)
         | 
| 93 | 
            -
                  encrypt(unencrypted_source) if | 
| 94 | 
            -
                  return [@cipher_text].pack('m').chomp
         | 
| 112 | 
            +
                  encrypt(unencrypted_source) if unencrypted_source != nil
         | 
| 113 | 
            +
                  return [ @cipher_text ].pack('m').chomp
         | 
| 95 114 | 
             
                end
         | 
| 96 115 |  | 
| 97 | 
            -
                #Decrypts source using AES 256 CBC, using @key and @iv
         | 
| 98 | 
            -
                # | 
| 99 | 
            -
                # | 
| 100 | 
            -
                # | 
| 116 | 
            +
                # Decrypts source using AES 256 CBC, using @key and @iv
         | 
| 117 | 
            +
                #
         | 
| 118 | 
            +
                # @param encrypted_source [String|File]
         | 
| 119 | 
            +
                # @param base64_source [Boolean] if true, then source is assumed to be base64 encoded.
         | 
| 120 | 
            +
                # @return [String] String representing the original unencypted source
         | 
| 101 121 | 
             
                def decrypt(encrypted_source, base64_source = false)
         | 
| 102 | 
            -
                  encrypted_source = StringIO.new(encrypted_source) if | 
| 103 | 
            -
                  read_count = base64_source ? 5464:4096
         | 
| 122 | 
            +
                  encrypted_source = StringIO.new(encrypted_source) if encrypted_source.instance_of?(String)
         | 
| 123 | 
            +
                  read_count = base64_source ? 5464 : 4096
         | 
| 104 124 | 
             
                  decode_cipher = OpenSSL::Cipher.new(AES_256_CBC)
         | 
| 105 125 | 
             
                  decode_cipher.decrypt
         | 
| 106 126 | 
             
                  decode_cipher.key = @key
         | 
| 107 127 | 
             
                  decode_cipher.iv = @iv
         | 
| 108 | 
            -
                  @plain_text =  | 
| 109 | 
            -
                  while (et = encrypted_source.read(read_count)) != nil | 
| 110 | 
            -
                    @plain_text << (base64_source ? decode_cipher.update(et. | 
| 128 | 
            +
                  @plain_text = ''
         | 
| 129 | 
            +
                  while (et = encrypted_source.read(read_count)) != nil
         | 
| 130 | 
            +
                    @plain_text << (base64_source ? decode_cipher.update(et.unpack1('m')) : decode_cipher.update(et))
         | 
| 111 131 | 
             
                  end
         | 
| 112 132 | 
             
                  @plain_text << decode_cipher.final
         | 
| 113 133 | 
             
                end
         | 
| 114 | 
            -
             | 
| 115 | 
            -
                #Generates a new key using Digest SHA256 in @key.
         | 
| 116 | 
            -
                # | 
| 117 | 
            -
             | 
| 118 | 
            -
             | 
| 119 | 
            -
             | 
| 120 | 
            -
             | 
| 121 | 
            -
             | 
| 122 | 
            -
             | 
| 123 | 
            -
             | 
| 124 | 
            -
                # | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 127 | 
            -
                 | 
| 128 | 
            -
             | 
| 129 | 
            -
                 | 
| 130 | 
            -
             | 
| 131 | 
            -
                # | 
| 134 | 
            +
             | 
| 135 | 
            +
                # Generates a new key using Digest SHA256 in @key.
         | 
| 136 | 
            +
                #
         | 
| 137 | 
            +
                # @return [String] Base64 encoded string, @key
         | 
| 138 | 
            +
                def self.gen_key_to_s
         | 
| 139 | 
            +
                  digest = Digest::SHA256.new
         | 
| 140 | 
            +
                  digest.update('symetric key')
         | 
| 141 | 
            +
                  return [ digest.digest ].pack('m').chomp
         | 
| 142 | 
            +
                end
         | 
| 143 | 
            +
             | 
| 144 | 
            +
                # Generate random AES_256_CBC initialization vector.
         | 
| 145 | 
            +
                #
         | 
| 146 | 
            +
                # @return [String] Base64 encoded initialization vector @iv
         | 
| 147 | 
            +
                def self.gen_iv_to_s
         | 
| 148 | 
            +
                  return [ OpenSSL::Cipher.new(AES_256_CBC).random_iv ].pack('m').chomp
         | 
| 149 | 
            +
                end
         | 
| 150 | 
            +
             | 
| 151 | 
            +
                # Generates a new key using Digest SHA256 in @key, and random AES_256_CBC initialization vector in @iv
         | 
| 152 | 
            +
                #
         | 
| 153 | 
            +
                # @return [String,String] Base64 encoded string, @key;
         | 
| 154 | 
            +
                #                  Base64 encoded initialization vector @iv
         | 
| 132 155 | 
             
                def self.gen_key_iv_to_s
         | 
| 133 | 
            -
             | 
| 156 | 
            +
                  return self.gen_key_to_s, self.gen_iv_to_s
         | 
| 134 157 | 
             
                end
         | 
| 135 | 
            -
             | 
| 136 | 
            -
                #Encrypts source using AES 256 CBC, using @key and @iv
         | 
| 137 | 
            -
                # | 
| 138 | 
            -
                # | 
| 158 | 
            +
             | 
| 159 | 
            +
                # Encrypts source using AES 256 CBC, using @key and @iv
         | 
| 160 | 
            +
                #
         | 
| 161 | 
            +
                # @param unencrypted_source [String|File]
         | 
| 162 | 
            +
                # @param key_string [String] optional base64 key to be used in encryption or decryption.
         | 
| 139 163 | 
             
                #    if nil, then key and iv are generated automatically. Recover the key with key_to_s(), or key_iv_to_s()
         | 
| 140 | 
            -
                # | 
| 164 | 
            +
                # @param iv_string [String ] optional base64 iv (initial vector) to be used in the encryption or decryption
         | 
| 141 165 | 
             
                #    Overwritten by auto generated iv, if key_string is nil. Recover with iv_to_str() or key_iv_to_s().
         | 
| 142 | 
            -
                # | 
| 143 | 
            -
                # | 
| 144 | 
            -
                # | 
| 166 | 
            +
                # @return [String,String,String] Binary string representing encrypted source;
         | 
| 167 | 
            +
                #                                base64 key, @key, so later decryption can be done;
         | 
| 168 | 
            +
                #                                base64 initial vector, @iv, so later decryption can be done
         | 
| 145 169 | 
             
                def self.encrypt(unencrypted_source, key_string = nil, iv_string = nil)
         | 
| 146 170 | 
             
                  aes = self.new(key_string, iv_string)
         | 
| 147 | 
            -
                  return aes.encrypt(unencrypted_source), aes.key_to_s, aes.iv_to_s | 
| 171 | 
            +
                  return aes.encrypt(unencrypted_source), aes.key_to_s, aes.iv_to_s
         | 
| 148 172 | 
             
                end
         | 
| 149 | 
            -
             | 
| 150 | 
            -
                #Converts encrypted source String, @cipher_text, into Base64 String
         | 
| 151 | 
            -
                # | 
| 152 | 
            -
                # | 
| 173 | 
            +
             | 
| 174 | 
            +
                # Converts encrypted source String, @cipher_text, into Base64 String
         | 
| 175 | 
            +
                #
         | 
| 176 | 
            +
                # @param unencrypted_source [String|File] which must be present, as AES_256 class is created here.
         | 
| 177 | 
            +
                # @param key_string [String] optional base64 key to be used in encryption or decryption.
         | 
| 153 178 | 
             
                #    if nil, then key and iv are generated automatically. Recover the key with key_to_s(), or key_iv_to_s()
         | 
| 154 | 
            -
                # | 
| 179 | 
            +
                # @param iv_string [String ] optional base64 iv (initial vector) to be used in the encryption or decryption
         | 
| 155 180 | 
             
                #    Overwritten by auto generated iv, if key_string is nil. Recover with iv_to_str() or key_iv_to_s().
         | 
| 156 | 
            -
                # | 
| 157 | 
            -
                # | 
| 158 | 
            -
                # | 
| 181 | 
            +
                # @return [String,String,String] Base64 string representing encrypted source;
         | 
| 182 | 
            +
                #                                base64 key, @key, so later decryption can be done;
         | 
| 183 | 
            +
                #                                base64 initial vector, @iv, so later decryption can be done
         | 
| 159 184 | 
             
                def self.cipher_to_s(unencrypted_source, key_string = nil, iv_string = nil)
         | 
| 160 185 | 
             
                  aes = self.new(key_string, iv_string)
         | 
| 161 | 
            -
                  return aes.cipher_to_s(unencrypted_source), aes.key_to_s, aes.iv_to_s | 
| 186 | 
            +
                  return aes.cipher_to_s(unencrypted_source), aes.key_to_s, aes.iv_to_s
         | 
| 162 187 | 
             
                end
         | 
| 163 | 
            -
             | 
| 164 | 
            -
                #Creates an AES class and then Decrypts source using AES 256 CBC, using @key and @iv
         | 
| 165 | 
            -
                # | 
| 166 | 
            -
                # | 
| 167 | 
            -
                # | 
| 188 | 
            +
             | 
| 189 | 
            +
                # Creates an AES class and then Decrypts source using AES 256 CBC, using @key and @iv
         | 
| 190 | 
            +
                #
         | 
| 191 | 
            +
                # @param encrypted_source [String|File]
         | 
| 192 | 
            +
                # @param base64_source [Boolean] if true, then source is assumed to be base64 encoded.
         | 
| 193 | 
            +
                # @param key_string [String] optional base64 key to be used in encryption or decryption.
         | 
| 168 194 | 
             
                #    if nil, then key and iv are generated automatically. Recover the key with key_to_s(), or key_iv_to_s()
         | 
| 169 | 
            -
                # | 
| 195 | 
            +
                # @param iv_string [String ] optional base64 iv (initial vector) to be used in the encryption or decryption
         | 
| 170 196 | 
             
                #    Overwritten by auto generated iv, if key_string is nil. Recover with iv_to_str() or key_iv_to_s().
         | 
| 171 | 
            -
                # | 
| 172 | 
            -
                def self.decrypt(encrypted_source, base64_source=false, key_string = nil, iv_string = nil)
         | 
| 197 | 
            +
                # @return [String] String representing the original unencypted source
         | 
| 198 | 
            +
                def self.decrypt(encrypted_source, base64_source = false, key_string = nil, iv_string = nil)
         | 
| 173 199 | 
             
                  aes = self.new(key_string, iv_string)
         | 
| 174 200 | 
             
                  return aes.decrypt(encrypted_source, base64_source)
         | 
| 175 201 | 
             
                end
         | 
| 176 202 | 
             
              end
         | 
| 177 203 | 
             
            end
         | 
| 178 | 
            -
             | 
| 179 | 
            -
             | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: wikk_aes_256
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.7
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Rob Burrowes
         | 
| 8 | 
            -
            autorequire: | 
| 8 | 
            +
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2022-06-05 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: hoe-yard
         | 
| @@ -30,14 +30,14 @@ dependencies: | |
| 30 30 | 
             
                requirements:
         | 
| 31 31 | 
             
                - - "~>"
         | 
| 32 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            -
                    version: '3. | 
| 33 | 
            +
                    version: '3.23'
         | 
| 34 34 | 
             
              type: :development
         | 
| 35 35 | 
             
              prerelease: false
         | 
| 36 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 37 | 
             
                requirements:
         | 
| 38 38 | 
             
                - - "~>"
         | 
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            -
                    version: '3. | 
| 40 | 
            +
                    version: '3.23'
         | 
| 41 41 | 
             
            description: Class for AES 256 encryption of text.
         | 
| 42 42 | 
             
            email:
         | 
| 43 43 | 
             
            - r.burrowes@auckland.ac.nz
         | 
| @@ -53,11 +53,11 @@ files: | |
| 53 53 | 
             
            - README.md
         | 
| 54 54 | 
             
            - Rakefile
         | 
| 55 55 | 
             
            - lib/wikk_aes_256.rb
         | 
| 56 | 
            -
            homepage:  | 
| 56 | 
            +
            homepage: https://wikarekare.github.io/wikk_aes_256/
         | 
| 57 57 | 
             
            licenses:
         | 
| 58 58 | 
             
            - MIT
         | 
| 59 59 | 
             
            metadata: {}
         | 
| 60 | 
            -
            post_install_message: | 
| 60 | 
            +
            post_install_message:
         | 
| 61 61 | 
             
            rdoc_options:
         | 
| 62 62 | 
             
            - "--markup"
         | 
| 63 63 | 
             
            - markdown
         | 
| @@ -78,9 +78,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 78 78 | 
             
                - !ruby/object:Gem::Version
         | 
| 79 79 | 
             
                  version: '0'
         | 
| 80 80 | 
             
            requirements: []
         | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
            signing_key: 
         | 
| 81 | 
            +
            rubygems_version: 3.2.22
         | 
| 82 | 
            +
            signing_key:
         | 
| 84 83 | 
             
            specification_version: 4
         | 
| 85 84 | 
             
            summary: Class for AES 256 encryption of text.
         | 
| 86 85 | 
             
            test_files: []
         |