webget_ruby_secure_token 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.
- data/lib/webget_ruby_secure_token.rb +38 -0
- data/test/webget_ruby_secure_token_test.rb +16 -0
- data.tar.gz.sig +1 -0
- metadata +87 -0
- metadata.gz.sig +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
=begin rdoc
|
|
2
|
+
|
|
3
|
+
= WebGet Ruby Gem: SecureToken
|
|
4
|
+
|
|
5
|
+
Author:: Joel Parker Henderson, joelparkerhenderson@gmail.com
|
|
6
|
+
Copyright:: Copyright (c) 2006-2010 Joel Parker Henderson
|
|
7
|
+
License:: CreativeCommons License, Non-commercial Share Alike
|
|
8
|
+
License:: LGPL, GNU Lesser General Public License
|
|
9
|
+
|
|
10
|
+
Random token generator to create strong secure text tokens.
|
|
11
|
+
|
|
12
|
+
==Example
|
|
13
|
+
SecureToken.new => "kavzwbnxremyqlkw"
|
|
14
|
+
|
|
15
|
+
This generates a 16-character token of all lowercase letters,
|
|
16
|
+
using Ruby's securerandom methods.
|
|
17
|
+
|
|
18
|
+
SecureToken is a string, so you can do any string methods on it.
|
|
19
|
+
You can change how tokens are randomly created, however you want.
|
|
20
|
+
|
|
21
|
+
=end
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# Ruby 1.8.6 and older does not have a secure random_number method,
|
|
25
|
+
# so we require our secure random gem which provides the method.
|
|
26
|
+
if !defined?(SecureRandom) then require 'webget_ruby_secure_random' end
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class SecureToken < String
|
|
30
|
+
|
|
31
|
+
COUNT = 16
|
|
32
|
+
CHARS = ['a','b','c','d','e','f','g','h','j','k','m','n','p','r','s','t','u','v','w','x','y','z']
|
|
33
|
+
|
|
34
|
+
def initialize
|
|
35
|
+
super(Array.new(COUNT){CHARS[SecureRandom.random_number(CHARS.size)]}.join)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'webget_ruby_secure_token'
|
|
3
|
+
|
|
4
|
+
class Testing < Test::Unit::TestCase
|
|
5
|
+
|
|
6
|
+
def test_all
|
|
7
|
+
20.times{
|
|
8
|
+
x=SecureToken.new
|
|
9
|
+
assert(x.is_a?(String))
|
|
10
|
+
assert_equal(x.length,SecureToken::COUNT)
|
|
11
|
+
assert(x=~/^[a-z]+$/,"lowercase letters:#{x}")
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
data.tar.gz.sig
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
�a�#��t�����?�9O1� �h�k���������@nT;��-\���ө<��� G���t�oBGvE����o�˪fh��(�dN^jf_��:�
|
metadata
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: webget_ruby_secure_token
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.2.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- WebGet
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain:
|
|
11
|
+
- |
|
|
12
|
+
-----BEGIN CERTIFICATE-----
|
|
13
|
+
MIIDvDCCAyWgAwIBAgIJAIlSqEkDQaZIMA0GCSqGSIb3DQEBBQUAMIGbMQswCQYD
|
|
14
|
+
VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5j
|
|
15
|
+
aXNjbzETMBEGA1UEChMKV2ViR2V0LmNvbTETMBEGA1UECxMKV2ViR2V0LmNvbTET
|
|
16
|
+
MBEGA1UEAxMKV2ViR2V0LmNvbTEgMB4GCSqGSIb3DQEJARYRd2ViZ2V0QHdlYmdl
|
|
17
|
+
dC5jb20wHhcNMDkwMjI2MTk0NDU4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QeWmoUjGh3Z0ZR0JlhU0ln8899LuJ3
|
|
32
|
+
DXnLFY0cVuBnNDMOOFl8vk1qIcZjcTovhzgcixpG6Uk5qmUsKHRLQf4oQJx7TfLK
|
|
33
|
+
-----END CERTIFICATE-----
|
|
34
|
+
|
|
35
|
+
date: 2010-02-17 00:00:00 -08:00
|
|
36
|
+
default_executable:
|
|
37
|
+
dependencies:
|
|
38
|
+
- !ruby/object:Gem::Dependency
|
|
39
|
+
name: webget_ruby_secure_random
|
|
40
|
+
type: :runtime
|
|
41
|
+
version_requirement:
|
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: 1.2.0
|
|
47
|
+
version:
|
|
48
|
+
description:
|
|
49
|
+
email: webget@webget.com
|
|
50
|
+
executables: []
|
|
51
|
+
|
|
52
|
+
extensions: []
|
|
53
|
+
|
|
54
|
+
extra_rdoc_files: []
|
|
55
|
+
|
|
56
|
+
files:
|
|
57
|
+
- lib/webget_ruby_secure_token.rb
|
|
58
|
+
has_rdoc: true
|
|
59
|
+
homepage: http://webget.com/
|
|
60
|
+
licenses: []
|
|
61
|
+
|
|
62
|
+
post_install_message:
|
|
63
|
+
rdoc_options: []
|
|
64
|
+
|
|
65
|
+
require_paths:
|
|
66
|
+
- lib
|
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
|
+
requirements:
|
|
69
|
+
- - ">="
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: "0"
|
|
72
|
+
version:
|
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
|
+
requirements:
|
|
75
|
+
- - ">="
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: "0"
|
|
78
|
+
version:
|
|
79
|
+
requirements: []
|
|
80
|
+
|
|
81
|
+
rubyforge_project:
|
|
82
|
+
rubygems_version: 1.3.5
|
|
83
|
+
signing_key:
|
|
84
|
+
specification_version: 3
|
|
85
|
+
summary: "WebGet Ruby Gem: SecureToken to generate a cryptographic string that is web-friendly and user-friendly"
|
|
86
|
+
test_files:
|
|
87
|
+
- test/webget_ruby_secure_token_test.rb
|
metadata.gz.sig
ADDED
|
Binary file
|