n_cipher 0.1.0 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d179a1db88d763c25848f97490336967aff7c1f5
4
- data.tar.gz: 616bb27ac032d31aaabce2460b529390e4497455
3
+ metadata.gz: 991e2699223167165235fc110af12ff68978529f
4
+ data.tar.gz: a89eb6c237e1ef29aa6a64f82f7f4efa6a1e771a
5
5
  SHA512:
6
- metadata.gz: 0aa157e5cb20e5ba4df63c3f49cf6a4c8c9647804ce3d914bda5e7012476a4811883a3f0a4ee2ca58317d83ec76c1f0ba047e3ab1b11d7ee5fc7ba0bdaae09cf
7
- data.tar.gz: e54579c1aec4b3a0b72a0a251d7eb660afbd429fd7ccd48f8957a973d7778bb4ce19670df79c9aaaa937c2d606e5b5b58fad348bf81d7a046119dbd4f7dda065
6
+ metadata.gz: cb3907eb9c083bb27d5b7dbe452f4ee741ba4067a02b002188db4c6d52691f1c798076f8bad79c21e81f610904a3196a5f1ef39a7aa14dc1d6751ffb007be140
7
+ data.tar.gz: fb17a9a65302c885d0f71921e8d2d966c6187ebf764907fdddf28c724de73d9c6aa4d8b68f653a2646ca62bda1943fbeef72dc9c3cd62ad23fbdb26cbf1b114a
data/README.md CHANGED
@@ -1,6 +1,40 @@
1
1
  # NCipher
2
2
 
3
+ [![Gem](https://img.shields.io/gem/v/n_cipher.svg)]()
3
4
  [![Travis branch](https://img.shields.io/travis/844196/n_cipher.svg)](https://travis-ci.org/844196/n_cipher)
4
5
  [![Coveralls branch](https://img.shields.io/coveralls/844196/n_cipher/master.svg)](https://coveralls.io/github/844196/n_cipher)
5
6
  [![Code Climate](https://img.shields.io/codeclimate/github/844196/n_cipher.svg)](https://codeclimate.com/github/844196/n_cipher)
6
- [![GitHub license](https://img.shields.io/github/license/844196/n_cipher.svg)](LICENSE)
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'n_cipher'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ ```shellsession
19
+ $ bundle
20
+ ```
21
+
22
+ Or install it yourself as:
23
+
24
+ ```shellsession
25
+ $ gem install n_cipher
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ```ruby
31
+ require 'n_cipher'
32
+
33
+ NCipher::encode('にゃんぱす', seed: 'おうどん', delimiter: 'ひげ')
34
+ #=> "んおおうどどんひげんおおどおおんひげんおおどうおんひげんおおうんおうひげんおおううどうひげ"
35
+
36
+ NCipher::decode(
37
+ 'んおおうどどんひげんおおどおおんひげんおおどうおんひげんおおうんおうひげんおおううどうひげ',
38
+ seed: 'おうどん', delimiter: 'ひげ')
39
+ #=> "にゃんぱす"
40
+ ```
@@ -1,3 +1,3 @@
1
1
  module NCipher
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/n_cipher.rb CHANGED
@@ -20,6 +20,8 @@ module NCipher
20
20
  raise ArgumentError, 'Invalid argument.' if obj.empty?
21
21
  end
22
22
  raise ArgumentError, 'Seed must be 2 to 10 characters.' unless seed.size.between?(2,10)
23
+ raise ArgumentError, 'Seed and delimiter are deplicated.' unless (seed.split(//).uniq.sort & delimiter.split(//).uniq.sort) == []
24
+ raise ArgumentError, 'Invalid seed.' unless seed.split(//).size == seed.split(//).uniq.size
23
25
 
24
26
  string.unpack('U*').map {|c| c.to_s(seed.size).gsub(/./, convert_table(seed, :encode)).concat(delimiter) }.join
25
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: n_cipher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaya Takeda
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-07 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler