Manfred-Turippu 0.1.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.
Files changed (3) hide show
  1. data/README +8 -0
  2. data/lib/tripcode.rb +21 -0
  3. metadata +55 -0
data/README ADDED
@@ -0,0 +1,8 @@
1
+ ,-= Turippu!
2
+ |
3
+ | A trip-code library for Ruby
4
+ |
5
+ | > Tripcode.hash('password')
6
+ |
7
+ | Music suggestion: The Electric Flag – A Long Time Comin'
8
+ `-===
@@ -0,0 +1,21 @@
1
+ # Implements operations concerning tripcodes
2
+ module Tripcode
3
+ FORBIDDEN_IN_SALT = ':;<=>?@[\]^_`'
4
+ FORBIDDEN_ALTERNATIVE = 'ABCDEFGabcdef'
5
+
6
+ # Generates the tripcode for a certain password based on the recipe described on Wikipedia:
7
+ #
8
+ # 1. Convert the input to Shift JIS. (Ignored by this implementation)
9
+ # 2. Generate the salt as follows:
10
+ # - Take the second and third characters of the string obtained by appending H. to the end of the input.
11
+ # - Replace any characters not between . and z with .
12
+ # - Replace any of the characters in :;<=>?@[\]^_` with the corresponding character from ABCDEFGabcdef.
13
+ # 3. Call the crypt() function with the input and salt.
14
+ # 4. Return the last 10 characters. (compressional data harvest)
15
+ def self.hash(password)
16
+ salt = (password + 'H.')[1..2]
17
+ salt.gsub!(/[^a-zA-Z0-9\.]/, '.')
18
+ salt.tr!(FORBIDDEN_IN_SALT, FORBIDDEN_ALTERNATIVE)
19
+ password.crypt(salt)[-10..-1]
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Manfred-Turippu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Manfred Stienstra
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-26 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: A trip-code library for Ruby.
17
+ email: manfred@fngtps.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ files:
25
+ - lib/tripcode.rb
26
+ - README
27
+ has_rdoc: true
28
+ homepage: http://manfred.github.com
29
+ post_install_message:
30
+ rdoc_options:
31
+ - --inline-source
32
+ - --charset=UTF-8
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: "0"
40
+ version:
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
47
+ requirements: []
48
+
49
+ rubyforge_project:
50
+ rubygems_version: 1.2.0
51
+ signing_key:
52
+ specification_version: 2
53
+ summary: A library to generate trip-codes for a password as a way to do weak authentication.
54
+ test_files: []
55
+