Giter Site home page Giter Site logo

cryptoaddressvalidator's Introduction

CryptoAddressValidator

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Adds a Laravel validator for various cryptocurrency address formats.

Currently adds a onion and bitcoin validator. Planning to add the following soon:

  • Dash addresses
  • Dogecoin addresses
  • Ethereum addresses (only very basic)
  • Litecoin addresses
  • Monero addresses

Also planning to create the following validators under another project

  • GPG pubkey
  • GPG signed data
  • Generic Base38 Validator
  • Generic Base32 Validator
  • Generic Hex validator
  • vinkla/laravel-hashids validator
  • CC validator (Luhn digit check algorithm)

Install

Via Composer

$ composer require DeftNerd/CryptoAddressValidator

Add the following to the providers array in your config/app.php file

DeftNerd\CryptoAddressValidator\CryptoAddressServiceProvider::class

Usage

Test any onion address to see if it follows the format

Base32, 16 characters, ends in '.onion'

Validator::make(['test' => 'facebookcorewwwi.onion'], ['test' => 'onion'])->passes(); //true

Validator::make(['test' => 'notarealonionaddress.onion'], ['test' => 'onion'])->passes(); //false

Validator::make(['test' => 'facebook.com'], ['test' => 'onion'])->passes(); //false

Test a Bitcoin address to see if it's valid.

Checks for proper Base58 encoding, tests the checksum, verifies the network prefix byte is one of (mainnet regular, mainnet p2sh, testnet regular, testnet p2sh)

Validator::make(['test' => '1HB5XMLmzFVj8ALj6mfBsbifRoD4miY36v'], ['test' => 'bitcoin'])->passes(); // true (Bitcoin address)

Validator::make(['test' => 'n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi'], ['test' => 'bitcoin'])->passes(); // true (Bitcoin Testnet address)

Validator::make(['test' => 'jsd8j8jksdjf9sj98'], ['test' => 'bitcoin'])->passes(); // false (random characters)

Validator::make(['test' => 'LQ3B36Yv2rBTxdgAdYpU2UcEZsaNwXeATk'], ['test' => 'bitcoin'])->passes(); // false (Litecoin address)

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

cryptoaddressvalidator's People

Contributors

deftnerd avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.