strdes 0.0.1
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 +15 -0
- data/lib/strdes.rb +40 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZmM4N2IwNGNlMDZhOWI4ZTgzMzA0MGZlNjVmMGRlZmRiOWZhZmE0OQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NjMyYmUyM2YwOTQxNjhiMmE3ZjFmYmYwOWFiZDc0ZGNlMzgyZDM0MA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NTU2MGJhNDFkM2Q3OTdmZDFhZTNjN2IxMDkxNzAwYmQ4MmVlMjEyNThmNmM0
|
10
|
+
OGFlMmYwNWJmZGJjYmY0NzU0NmY3ZWM1Y2FkODg5MzE3OWRiNDg0M2U4MzEx
|
11
|
+
ZjZkN2RhMzhkYWQzZDU1Y2FlNzI5MTc3NDRjNjdjNDlmY2E0ZTQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YzBhNDMyZmJjZjY4ZTRiYWIxMTQ2MWU2NWQ1ZGZhNTY0MTZlYTliN2I0Yzkx
|
14
|
+
NGVlODliOGVjYTBmYjI5MTY0MWNlMTgyYzRmZWM0M2Y1ZmYzMWQ5NGI3Mjdh
|
15
|
+
YjQ5NGJiMDA5NWU0NTMyODAxZmM0ZDAyM2VmMDhjNWQ2YThlMzY=
|
data/lib/strdes.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# String encryption and decryption
|
2
|
+
class Strdes
|
3
|
+
require 'openssl'
|
4
|
+
require 'base64'
|
5
|
+
|
6
|
+
ALG = 'DES-EDE3-CBC'
|
7
|
+
KEY = 'uryeiowl'
|
8
|
+
DES_KEY = 'uyiofs3w'
|
9
|
+
|
10
|
+
class << self
|
11
|
+
# String encryption
|
12
|
+
# Example:
|
13
|
+
# >> Strdes.encode("need encryption string")
|
14
|
+
# => "SuO9XVv5gV3TqeNIocUTp-5APhtRTeMr"
|
15
|
+
# Arguments:
|
16
|
+
# str: (String)
|
17
|
+
def encode(str)
|
18
|
+
des = OpenSSL::Cipher::Cipher.new ALG
|
19
|
+
des.pkcs5_keyivgen KEY, DES_KEY
|
20
|
+
des.encrypt
|
21
|
+
cipher = des.update str
|
22
|
+
cipher << des.final
|
23
|
+
Base64.urlsafe_encode64 cipher
|
24
|
+
end
|
25
|
+
|
26
|
+
# String decryption
|
27
|
+
# Example:
|
28
|
+
# >> Strdes.decode("SuO9XVv5gV3TqeNIocUTp-5APhtRTeMr")
|
29
|
+
# => "need encryption string"
|
30
|
+
# Arguments:
|
31
|
+
# str: (String)
|
32
|
+
def decode(str)
|
33
|
+
str = Base64.urlsafe_decode64 str
|
34
|
+
des = OpenSSL::Cipher::Cipher.new ALG
|
35
|
+
des.pkcs5_keyivgen KEY, DES_KEY
|
36
|
+
des.decrypt
|
37
|
+
des.update(str) + des.final
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: strdes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- fxhover
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple string encryption and decryption gem
|
14
|
+
email: 736698959@qq.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/strdes.rb
|
20
|
+
homepage: http://rubygems.org/gems/strdes
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.3.6
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.2.2
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: strdes!
|
44
|
+
test_files: []
|