Skip to content

Instantly share code, notes, and snippets.

View icostan's full-sized avatar
💪
Go big, go fast, go hard or go home!

Iulian Costan icostan

💪
Go big, go fast, go hard or go home!
View GitHub Profile

Keybase proof

I hereby claim:

  • I am icostan on github.
  • I am icostan (https://keybase.io/icostan) on keybase.
  • I have a public key ASDKtREJZfoZi1cp8-lpg7dO9i9g5mI02wnhtV3_1Qc7_Ao

To claim this, I am signing this object:

@icostan
icostan / bitwarden.rb
Last active June 11, 2021 22:11
Transform exported iCloud passwords into Bitwarden's CSV format.
#!/usr/bin/env ruby
require 'csv'
CSV.open('bitwarden.csv', 'w') do |csv|
csv << ['folder', 'favorite', 'type', 'name', 'notes', 'fields', 'login_uri', 'login_username', 'login_password', 'login_totp']
CSV.open('~/Desktop/pm_export.csv', headers: true).each do |row|
data = ['', 0, 'login', row['Title'], '', '', row['Login URL'], row['Login Username'], row['Login Password'], '']
csv << data
@icostan
icostan / rsa.md
Last active March 23, 2019 13:37

Overview

"If you can't explain it simply, you don't understand it well enough" - Einstein

RSA (Rivest-Shamir-Adleman) needs no introduction, it is well known and most used public-key cryptosystem that governs our digital lives.

Here is my take, a simple implementation in 10 lines of Ruby code that is neither the best implementation nor the most efficient one but is enough for the purpose of this article.

 1  p = 7

2 q = 11

Release: Cryptos-ruby project

I just want to announce the very first release [v0.0.3] of Cryptos-ruby project, a simple and very easy to use Ruby API to manipulate multiple crypto coins.

For more information please check Github project page.

Features

  • Generate private/public keys
  • Generate Bitcoin/Litecoin addresses (more to come)
  • Create Bitcoin/Litecoin transactions
# require 'tmpdir'
RSpec.describe Cryptos::Bitcoin do
let(:to_address) {
Cryptos::Bitcoin::Address.new Cryptos::PublicKey.new Cryptos::PrivateKey.generate
}
before :all do
@cli = Cryptos::Connectors::Cli.new
@private_key = Cryptos::PrivateKey.generate

The hard way - Bitcoin: Transaction

This is Part 2 of 'The hard way - Bitcoin' series and I will start with 'the easy way' section first because even this gets a bit complex, then will continue with the hard stuff, crafting a Bitcoin transaction from scratch using basic math and cryptography.

A. The easy way

Create private key, public key and address

We are going to generate private key, public key and Bitcoin testnet address to be used in this article.

The hard way series - Bitcoin: private key, public key, address

This article is all about two ways of generating a Bitcoin address: the hard way using simple math and the easy way using an existing Bitcoin library.

A. The hard way

In this section I am going to use simple math functions like addition and multiplication to generate a valid Bitcoin address starting from a number, the private key and calculating everything all the way up to public key and final Bitcoin address.

TL;DR;

@icostan
icostan / bitcoin-address.rb
Last active October 9, 2018 11:41
Generate Bitcoin address
require 'digest'
#
# secp256k1 domain parameters
#
G = '0479BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8'
Gx = 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798
Gy = 0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8
puts "Base point: #{G}"
puts "Base point X coordinate: #{Gx.to_i}"