ntc-rcrypto is module ruby cryptography.
Add this line to your application's Gemfile:
gem 'ntc-rcrypto'
And then execute:
bundle install
Or install it yourself as:
gem install ntc-rcrypto
Use encode/decode Base64Url
require 'rcrypto'
sss = Rcrypto::SSS.new
s = "nghiatcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
puts s
puts s.length
# creates a set of shares
arr = sss.create(3, 6, s, true)
# puts arr
# combines shares into secret
s1 = sss.combine(arr[0...3], true)
puts s1
puts s1.length
s2 = sss.combine(arr[3...6], true)
puts s2
puts s2.length
s3 = sss.combine(arr[1...5], true)
puts s3
puts s3.length
Use encode/decode Hex
require 'rcrypto'
sss = Rcrypto::SSS.new
s = "nghiatcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
puts s
puts s.length
# creates a set of shares
arr = sss.create(3, 6, s, false)
# puts arr
# combines shares into secret
s1 = sss.combine(arr[0...3], false)
puts s1
puts s1.length
s2 = sss.combine(arr[3...6], false)
puts s2
puts s2.length
s3 = sss.combine(arr[1...5], false)
puts s3
puts s3.length
This code is under the Apache License v2.