Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Rubychain is a very simple implementation of a blockchain for education purposes. It is heavily inspired by the python version which can be found here: https://dev.to/aunyks/lets-build-the-tiniest-blockchain
There are only 2 classes which are /lib/rubychain/chain and /lib/rubychain/block
Rubychain::Chain
for creating, updating and exploring the blockchain
Rubychain::Block
for creating each individual block
Check out the instructions below or the specs to see how it all works
Add this line to your application's Gemfile:
gem 'rubychain'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rubychain
require 'rubychain'
add_next_block(prev_block, data)
=> Adds a new block to the blockchain with the given data and previous block
genesis_block
=> Returns the Genesis block
last_block
=> Returns the last block that was added to the blockchain
find_block(hash)
=> Returns a block from the blockchain with the given hash
blockchain
=> Returns the whole blockchain as an array
Initialize a new blockchain with a genesis block:
rc = Rubychain::Chain.new
rc.add_next_block(rc.last_block, "some data")
=> creates a new block with given data and previous block
rc.genesis_block
=> returns the genesis block
rc.last_block
=> returns the last block on the blockchain
rc.find_block(hash)
=> return the block with the given hash
rc.blockchain
=> [genesis_block, block2] => Returns the whole blockchain as an array
index
=> returns the blocks index
timestamp
=> returns the blocks timestamp
data
=> returns the blocks data
prev_hash
=> returns the previous blocks hash
hash
=> returns a SHA256 hash representation of all the items in the block
myblock = rc.last_block
or
myblock = rc.find_block(hash)
or directly
myblock = Rubychain::Block.new(1, Time.now, "Hello World", "abc123")
myblock.index
=> 1
myblock.timestamp
=> Time of creation
myblock.data
=> "Hello World"
myblock.pre_hash
=> "abc123"
myblock.hash
=> sha.hexdigest of index, timestamp, data and previous block hash
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rubychain.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that rubychain demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.