Skip to content

Latest commit

 

History

History
73 lines (60 loc) · 3.31 KB

README.md

File metadata and controls

73 lines (60 loc) · 3.31 KB

Randomface

Randomface is React component for generating vector face-like figures from SHA-256 hash.

About

Although various random face/avatar generators have existed for a long time, none of them provide genuine randomness in face generation. Many rely on pre-defined images of facial features combined with repetitive patterns, which diminishes the uniqueness and individuality of generated faces.

Randomface takes a different approach by keeping only the positions of facial features fixed while randomizing everything else. This results in a vast range of simple abstract facial expressions, making each face unique and easily distinguishable even in large groups.

And it is lightweight - it doesn't have any external dependencies and outputs a plain SVG. The only requirement is a SHA-256 hash for a face input, which should not be a problem to obtain on any modern platform.

Basic Usage

Install package from npm:

npm install randomface-react

To generate a random face - SHA-256 hash value is required for input. It should not be a problem to obtain it on any modern platform. If you use Randomface to generate users avatars - we suggest to use unique constant user identifier as a hash input (e.g. user id)

import { RandomfaceSVG } from 'randomface-react';

// In the browser, you can use the SubtleCrypto API to create a hash for the given value.
// In NodeJS you can use native "crypto" package. Other open source solutions are available as well.
let hash = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';

function MyFace() {
  return (
    <RandomfaceSVG
      sha256hash={hash}
      width={100}
      height={100}
      style={{
        fill: '#ffffff',
      }}
    ></RandomfaceSVG>
  );
}