base58_gmp 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ = 0.0.4
2
+ - Add flickr_to_gmp transcoding
3
+ - Document Flickr and GMP transcoding
4
+
1
5
  = 0.0.3
2
6
  - Minor fixes.
3
7
 
@@ -1,12 +1,12 @@
1
1
  = Base58GMP
2
2
 
3
- High speed Base58 encoding using GMP with MD5 support
3
+ High speed Base58 encoding using GMP with MD5 support and transcoding between GMP and Flickr implementations.
4
4
 
5
5
  == Installation
6
6
 
7
7
  === Gem Installation
8
8
 
9
- Download and install base58_gmp with the following.
9
+ Download and install base58_gmp with the following:
10
10
 
11
11
  gem install base58_gmp
12
12
 
@@ -16,13 +16,35 @@ Download and install base58_gmp with the following.
16
16
  require 'base58_gmp'
17
17
 
18
18
  # Int to Base58
19
- Base58GMP.encode(12345) # => 4ER
20
-
19
+ Base58GMP.encode(12345) # => 4ER
20
+
21
21
  # MD5 Base58 Digest
22
22
  Base58GMP.md5('foo@bar.com') # => w6fdCRXnUXyz7EtDn5TgN9
23
23
 
24
+ # Convert between Flickr and GMP
25
+ Base58GMP.flickr_to_gmp('123456789abcdefghijk') # => 0123456789ABCDEFGHIJ
26
+ Base58GMP.gmp_to_flickr('0123456789ABCDEFGHIJ') # => 123456789abcdefghijk
27
+
24
28
  == Notes
25
29
 
30
+ === Base58 Implementations - Flickr and GMP
31
+
32
+ This class supports the Base58 implementations used by Flickr and GMP.
33
+
34
+ The Flickr implementation uses the [0-9a-zA-Z] Base62 alphabet excluding [0OIl] to improve human readability and is described here:
35
+
36
+ http://www.flickr.com/groups/api/discuss/72157616713786392/
37
+
38
+ The GMP implementation uses the [0-9A-Za-v] alphabet.
39
+
40
+ The encode and md5 functions use the Flickr implementation which can be converted to the GMP implementation using flickr_to_gmp.
41
+
42
+ === GMP
43
+
44
+ This class requires GMP 4.2.0 or above. Prior versions are limited to Base36.
45
+
46
+ === Base58 Decoding Support
47
+
26
48
  GMP-supported Base58 decoding is not currently provided as underlying support is not yet available in the Ruby GMP binding.
27
49
 
28
50
  For now, please use the base58 gem for Ruby-based decoding.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'base58_gmp'
3
- s.version = '0.0.3'
3
+ s.version = '0.0.4'
4
4
  s.date = '2011-11-06'
5
5
  s.summary = 'High speed Base58 encoding using GMP with MD5 support'
6
6
  s.description = 'Base58 encoding using the GNU Multiple Precision Arithmetic Library (GMP)'
@@ -9,12 +9,15 @@ class Base58GMP
9
9
 
10
10
  def self.number_to_base58( number )
11
11
  base58 = GMP::Z( number ).to_s( base = 58 )
12
- base58 = self.gmp_to_flickr( base58 )
13
- base58
12
+ self.gmp_to_flickr( base58 )
14
13
  end
15
14
 
16
15
  def self.gmp_to_flickr( base58_as_gmp )
17
- base58 = base58_as_gmp.tr( ALPHABET_GMP, ALPHABET_FLICKR )
16
+ base58_as_gmp.tr( ALPHABET_GMP, ALPHABET_FLICKR )
17
+ end
18
+
19
+ def self.flickr_to_gmp( base58_as_flickr )
20
+ base58_as_flickr.tr( ALPHABET_FLICKR, ALPHABET_GMP )
18
21
  end
19
22
 
20
23
  def self.md5_base58( data )
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: base58_gmp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Wang