Git Product home page Git Product logo

dart-crypto-hash's Introduction

Crypto Hash

The SHA-1 hash function implemented from scratch using pure dart.

I might add support for SHA-256 in the future.

Installing

For now, Crypto Hash is not available through pub dev, but you can still install it by adding the following to your dependencies:

dependencies:
  crypto_hash:
    git:
      url: https://github.com/lucas979797/dart-crypto-hash
      ref: main

Usage

A simple usage example:

import 'dart:convert';

import 'package:crypto_hash/crypto_hash.dart';

void main() {
  
  var hash = ShaOne.hashString('Hello World!');
  print(hash); // prints 2ef7bde68ce5404e97d5f042f95f89f1c232871

  // Unicode:
  var testString2 = 'こんにちは世界!';
  var hash2 = ShaOne.hashBytes(utf8.encode(testString2));
  print(hash2); // prints f66b68c765fae864106c7352d06be5df5ab510c3

  // Hashing a file: (see example directory for lorem.txt)
  var hash3 = ShaOne.hashFile('example/lorem.txt');
  print(hash3); // prints 4b0b2b74dab6099447a0471d6b390ce21055d508
}

Features and bugs

Let me know if you find any...

Other

I built this library to improve my understanding of hashing, and it is my first time implementing a (semi) secure hashing algorithm.

I found the following resources useful for learning:

I enjoyed doing the project in Dart, but if I did it again i'd just do it in C because there is a fair bit of extra manipulation that has to be done in Dart due to the language only supporting 64 bit integers.

dart-crypto-hash's People

Contributors

cycloss avatar

Watchers

 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.