Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ntc-rcrypto

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ntc-rcrypto

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

ntc-rcrypto

ntc-rcrypto is a module ruby cryptography.

Installation

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

1. An implementation of Shamir's Secret Sharing Algorithm 256-bits in Ruby

Usage

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

License

This code is under the Apache License v2.

FAQs

Package last updated on 27 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc