cryptology 1.1.0 → 1.2.0
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +8 -1
- data/lib/cryptology.rb +6 -0
- data/lib/cryptology/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22580eefd3a2222b7f68ac139bbc4e4e6ef2b1f8
|
4
|
+
data.tar.gz: 514c5cae153148249950f52a5b8cad69cb9f7d8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c565bdf3263f22f22223bacec3390c459d426302b632c8f42765e33c0afcdfdd45899a8cdcd40fbd2ca60b984343414c6e989352c67e4a6f74c9f74377106f9a
|
7
|
+
data.tar.gz: 2d7cb662f8a8718080e3d2f1bc0c7b5c2174ab9e73e3c82789079d8ed406946c943e8203fb7ae73d6534042f66617fb310dadf6841b43c63b2555d1ea014405d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -29,8 +29,12 @@ Cryptology.encrypt(data: data, key: key, cipher: cipher, iv: iv)
|
|
29
29
|
|
30
30
|
# Decrypting
|
31
31
|
Cryptology.decrypt(data: data, key: key, cipher: cipher, iv: iv)
|
32
|
+
|
33
|
+
# Check decryption ability (true if can be decrypted, false otherwise)
|
34
|
+
Cryptology.decryptable?(data: data, key: key, cipher: cipher, iv: iv)
|
32
35
|
```
|
33
36
|
|
37
|
+
|
34
38
|
Argument | Required? | Default | Comment
|
35
39
|
---------|-----------|---------------|-------------
|
36
40
|
data | **Yes** | n/a | Data to encrypt or decrypt
|
@@ -53,9 +57,12 @@ iv = OpenSSL::Cipher::Cipher.new(cipher).random_iv
|
|
53
57
|
# Encrypt our data
|
54
58
|
encrypted = Cryptology.encrypt(data: data, key: key, cipher: cipher, iv: iv)
|
55
59
|
|
60
|
+
# Verify that data can be decrypted
|
61
|
+
Cryptology.decryptable?(data: encrypted, key: key, cipher: cipher, iv: iv)
|
62
|
+
# => true
|
63
|
+
|
56
64
|
# Decrypt our data
|
57
65
|
plain = Cryptology.decrypt(data: encrypted, key: key, cipher: cipher, iv: iv)
|
58
|
-
|
59
66
|
```
|
60
67
|
|
61
68
|
### Cipher algorithms
|
data/lib/cryptology.rb
CHANGED
@@ -14,6 +14,12 @@ module Cryptology
|
|
14
14
|
.force_encoding('UTF-8').encode
|
15
15
|
end
|
16
16
|
|
17
|
+
def self.decryptable?(data:, key:, cipher: 'AES-256-CBC', iv: nil)
|
18
|
+
return true if decrypt(data: data, key: key, cipher: cipher, iv: iv)
|
19
|
+
rescue OpenSSL::Cipher::CipherError
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
|
17
23
|
private
|
18
24
|
|
19
25
|
def self.encrypt_data(data, key, cipher, iv)
|
data/lib/cryptology/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cryptology
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitriy Tarasov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|