digest-trip 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - rbx-19mode
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in digest-trip.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Yoshimoto
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Digest::Trip [![Build Status](https://travis-ci.org/beyond/digest-trip.png?branch=master)](https://travis-ci.org/beyond/digest-trip) [![Code Climate](https://codeclimate.com/github/beyond/digest-trip.png)](https://codeclimate.com/github/beyond/digest-trip)
2
+
3
+ �g���b�v�L�[����A2�����˂�̃g���b�v�i�ЂƂ�p�L���b�v�j�𐶐����܂��B
4
+
5
+ 10�������12���ɑΉ����Ă��܂��B���L�[�ɂ͑Ή����Ă��܂���B
6
+
7
+ ���O�ƃg���b�v�L�[�i#�ȍ~�̕�����j�́A�����Ńp�[�X���Ă��������B
8
+
9
+ ## Usage
10
+
11
+ require "digest/trip"
12
+
13
+ name= "name#password"
14
+ name, key = name.split "#", 2
15
+ trip = Digest::Trip.digest key
16
+ [name, trip].join "��" #=> "name��ozOtJW9BFA"
17
+
18
+ ## Installation
19
+
20
+ Add this line to your application's Gemfile:
21
+
22
+ gem 'digest-trip'
23
+
24
+ And then execute:
25
+
26
+ $ bundle
27
+
28
+ Or install it yourself as:
29
+
30
+ $ gem install digest-trip
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ task :default => [:spec]
5
+ begin
6
+ require 'rspec/core/rake_task'
7
+ RSpec::Core::RakeTask.new(:spec) do |spec|
8
+ spec.pattern = 'spec/**/*_spec.rb'
9
+ spec.rspec_opts = ['-cfs']
10
+ end
11
+ rescue LoadError => e
12
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'digest-trip/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "digest-trip"
8
+ gem.version = Digest::Trip::VERSION
9
+ gem.authors = ["Beyond"]
10
+ gem.email = ["beyond@be.go"]
11
+ gem.description = %q{ password digest for 2channel aka trip }
12
+ gem.summary = %q{ password digest for 2channel aka trip }
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency "rspec"
21
+ gem.add_development_dependency 'rake'
22
+ end
@@ -0,0 +1,3 @@
1
+ require 'digest'
2
+ require "digest-trip/version"
3
+ require "digest/trip"
@@ -0,0 +1,7 @@
1
+ require "digest"
2
+
3
+ module Digest
4
+ class Trip < Digest::Class
5
+ VERSION = "0.0.4"
6
+ end
7
+ end
@@ -0,0 +1,33 @@
1
+ require 'digest'
2
+ require "digest-trip/version"
3
+
4
+ require 'nkf'
5
+ require 'digest/sha1'
6
+ require 'base64'
7
+
8
+ module Digest
9
+ class Trip < Digest::Class
10
+ def reset
11
+ end
12
+
13
+ def update key
14
+ @key = key
15
+ end
16
+
17
+ def finish
18
+ key = NKF.nkf '-sxm0', @key
19
+
20
+ if key.bytesize >= 12
21
+ hash = Base64.encode64 Digest::SHA1.digest(key)
22
+ hash[0, 12].gsub '+', '.'
23
+ else
24
+ salt = (key + "H.")[1, 2]
25
+ salt = salt.gsub %r"[^\.-z]", "."
26
+ salt = salt.tr ":;<=>?@[\\]^_`", "ABCDEFGabcdef"
27
+
28
+ hash = key.crypt salt
29
+ hash[-10, 10]
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,62 @@
1
+ # -*- encoding: UTF-8 -*-
2
+ require File.expand_path(File.join('./', 'spec_helper'), File.dirname(__FILE__))
3
+
4
+ describe Digest::Trip do
5
+ subject { described_class.digest src }
6
+
7
+ describe "旧方式" do
8
+ TABLE_OLD = %w[
9
+ 0 IGEMrmvKLI
10
+ < 7VUOmXKYm6
11
+ 66666666 ixst/7hh6s
12
+ 000000 xSZBqZMT.M
13
+ 00000000 fV146ZJdLc
14
+ 00000000000 fV146ZJdLc
15
+ ああああ PZGoP0V9Oo
16
+ あああああ PZGoP0V9Oo
17
+ istrip /WG5qp963c
18
+ ハンカク xkjDBidf56
19
+ ]
20
+
21
+ Hash[ *TABLE_OLD ].each do |src, dest|
22
+ context "#{src} ->" do
23
+ let(:src) { src }
24
+ it { should == dest }
25
+ end
26
+ end
27
+ end
28
+
29
+ describe "新方式" do
30
+ context "12文字" do
31
+ TABLE_NEW_12 = %w[
32
+ 000000000000 wjEekmYN5HtF
33
+ 222222222222 qObcDgx.tp.y
34
+ >>>>>>>>>>>> /y08SHnxuoq/
35
+ ああああああ Wr9ky1zAYOBy
36
+ ハンカクハンカクハンカク IELfYnfdNlRs
37
+ ]
38
+
39
+ Hash[ *TABLE_NEW_12 ].each do |src, dest|
40
+ context "#{src} ->" do
41
+ let(:src) { src }
42
+ it { should == dest }
43
+ end
44
+ end
45
+ end
46
+
47
+ context "13文字" do
48
+ TABLE_NEW_13 = %w[
49
+ 1111111111111 N6TtUC4.aWi7
50
+ ]
51
+
52
+ Hash[ *TABLE_NEW_13 ].each do |src, dest|
53
+ context "#{src} ->" do
54
+ let(:src) { src }
55
+ it { should == dest }
56
+ end
57
+ end
58
+ end
59
+
60
+ end
61
+ end
62
+
@@ -0,0 +1,4 @@
1
+ # encoding: utf-8
2
+ require 'rubygems'
3
+ require 'digest-trip'
4
+
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: digest-trip
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Beyond
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: ! ' password digest for 2channel aka trip '
47
+ email:
48
+ - beyond@be.go
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - .rspec
55
+ - .travis.yml
56
+ - Gemfile
57
+ - LICENSE.txt
58
+ - README.md
59
+ - Rakefile
60
+ - digest-trip.gemspec
61
+ - lib/digest-trip.rb
62
+ - lib/digest-trip/version.rb
63
+ - lib/digest/trip.rb
64
+ - spec/diget-trip_spec.rb
65
+ - spec/spec_helper.rb
66
+ homepage: ''
67
+ licenses: []
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ segments:
79
+ - 0
80
+ hash: -1706437364636619958
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ segments:
88
+ - 0
89
+ hash: -1706437364636619958
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 1.8.25
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: password digest for 2channel aka trip
96
+ test_files:
97
+ - spec/diget-trip_spec.rb
98
+ - spec/spec_helper.rb