Description
NIdenticon is a library (available as NuGet package) that helps creating simple Identicons but is flexible enough to allow for tweaking the output to your heart's content.
This project was inspired by:
NIdenticon alternatives and similar packages
Based on the "Misc" category.
Alternatively, view NIdenticon alternatives based on common mentions on social networks and blogs.
-
Polly
Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. From version 6.0.1, Polly targets .NET Standard 1.1 and 2.0+. -
Humanizer
Humanizer meets all your .NET needs for manipulating and displaying strings, enums, dates, times, timespans, numbers and quantities -
Coravel
Near-zero config .NET library that makes advanced application features like Task Scheduling, Caching, Queuing, Event Broadcasting, and more a breeze! -
Hashids.net
A small .NET package to generate YouTube-like hashes from one or many numbers. Use hashids when you do not want to expose your database ids to the user. -
Scientist.NET
A .NET library for carefully refactoring critical paths. It's a port of GitHub's Ruby Scientist library -
WorkflowEngine
WorkflowEngine.NET - component that adds workflow in your application. It can be fully integrated into your application, or be in the form of a specific service (such as a web service). -
HidLibrary
This library enables you to enumerate and communicate with Hid compatible USB devices in .NET. -
DeviceId
A simple library providing functionality to generate a 'device ID' that can be used to uniquely identify a computer. -
Warden
Define "health checks" for your applications, resources and infrastructure. Keep your Warden on the watch. -
Aeron.NET
Efficient reliable UDP unicast, UDP multicast, and IPC message transport - .NET port of Aeron -
ByteSize
ByteSize is a utility class that makes byte size representation in code easier by removing ambiguity of the value being represented. ByteSize is to bytes what System.TimeSpan is to time. -
DeviceDetector.NET
The Universal Device Detection library will parse any User Agent and detect the browser, operating system, device used (desktop, tablet, mobile, tv, cars, console, etc.), brand and model. -
Mediator.Net
A simple mediator for .Net for sending command, publishing event and request response with pipelines supported -
SolidSoils4Arduino
C# .NET - Arduino library supporting simultaneous serial ASCII, Firmata and I2C communication -
FormHelper
ASP.NET Core - Transform server-side validations to client-side without writing any javascript code. (Compatible with Fluent Validation) -
Valit
Valit is dead simple validation for .NET Core. No more if-statements all around your code. Write nice and clean fluent validators instead! -
https://github.com/minhhungit/ConsoleTableExt
A fluent library to print out a nicely formatted table in a console application C# -
Validot
Validot is a performance-first, compact library for advanced model validation. Using a simple declarative fluent interface, it efficiently handles classes, structs, nested members, collections, nullables, plus any relation or combination of them. It also supports translations, custom logic extensions with tests, and DI containers. -
NaturalSort.Extension
๐ Extension method for StringComparison that adds support for natural sorting (e.g. "abc1", "abc2", "abc10" instead of "abc1", "abc10", "abc2"). -
Outcome.NET
Never write a result wrapper again! Outcome.NET is a simple, powerful helper for methods that return a value, but sometimes also need to return validation messages, warnings, or a success bit. -
SystemTextJson.JsonDiffPatch
High-performance, low-allocating JSON object diff and patch extension for System.Text.Json. Support generating patch document in RFC 6902 JSON Patch format. -
trybot
A transient fault handling framework including such resiliency solutions as Retry, Timeout, Fallback, Rate Limit and Circuit Breaker.
CodeRabbit: AI Code Reviews for Developers
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of NIdenticon or a related project?
README
[logo](nidenticonlogo.png) NIdenticon
"An Identicon is a visual representation of a hash value, usually of an IP address, that serves to identify a user of a computer system as a form of avatar while protecting the users' privacy. The original Identicon was a 9-block graphic, and the representation has been extended to other graphic forms by third parties." โ Wikipedia
NIdenticon is a library (available as NuGet package) that helps creating simple Identicons but is flexible enough to allow for tweaking the output to your heart's content.
This project was inspired by:
- Github โ Identicons!
- David Hamp-Gonsalves โ Generating Identicons
- Phil Haack โ Identicons as Graphical Digital Fingerprints
- Jeff Atwood โ Identicons for .NET
Usage
The most basic example is as follows:
var g = new IdenticonGenerator();
var mybitmap = g.Create("foo");
This will create an Identicon based on the string foo
with all other options default; another example is:
var g = new IdenticonGenerator();
var mybitmap = g.Create(HttpContext.Current.Request.UserHostAddress);
This creates an Identicon based on the IP-address of a remote host. The Identicon can be created with the following options:
- Dimensions (width, height default: 400, 400)
- Number of blocks, or "pixels" (horizontal, vertical default: 6, 6)
- Hash algorithm (default:
SHA512
) - Background color (default:
Transparent
) - Even the default string-encoding used can be specified (default: UTF-8)
This library only contains one the IdenticonGenerator
that has only one method: Create()
, but which is rich in overloads. These are:
Bitmap Create(byte[] value)
Bitmap Create(byte[] value, Size size)
Bitmap Create(byte[] value, Size size, Color backgroundcolor)
Bitmap Create(byte[] value, Size size, Color backgroundcolor, Size blocks)
Bitmap Create(byte[] value, Size size, Color backgroundcolor, Size blocks, IBlockGenerator[] blockgenerators)
Bitmap Create(byte[] value, Size size, Color backgroundcolor, Size blocks, IBlockGenerator[] blockgenerators, IBrushGenerator brushgenerator)
Bitmap Create(byte[] value, Size size, Color backgroundcolor, Size blocks, IBlockGenerator[] blockgenerators, IBrushGenerator brushgenerator, string algorithm)
Bitmap Create(IPAddress ipaddress)
Bitmap Create(IPAddress ipaddress, Size size)
Bitmap Create(IPAddress ipaddress, Size size, Color backgroundcolor)
Bitmap Create(IPAddress ipaddress, Size size, Color backgroundcolor, Size blocks)
Bitmap Create(IPAddress ipaddress, Size size, Color backgroundcolor, Size blocks, IBlockGenerator[] blockgenerators)
Bitmap Create(IPAddress ipaddress, Size size, Color backgroundcolor, Size blocks, IBlockGenerator[] blockgenerators, IBrushGenerator brushgenerator)
Bitmap Create(IPAddress ipaddress, Size size, Color backgroundcolor, Size blocks, IBlockGenerator[] blockgenerators, IBrushGenerator brushgenerator, string algorithm)
Bitmap Create(string value)
Bitmap Create(string value, Size size)
Bitmap Create(string value, Size size, Color backgroundcolor)
Bitmap Create(string value, Size size, Color backgroundcolor, Size blocks)
Bitmap Create(string value, Size size, Color backgroundcolor, Size blocks, Encoding encoding)
Bitmap Create(string value, Size size, Color backgroundcolor, Size blocks, Encoding encoding, IBlockGenerator[] blockgenerators)
Bitmap Create(string value, Size size, Color backgroundcolor, Size blocks, Encoding encoding, IBlockGenerator[] blockgenerators, IBrushGenerator brushgenerator)
Bitmap Create(string value, Size size, Color backgroundcolor, Size blocks, Encoding encoding, IBlockGenerator[] blockgenerators, IBrushGenerator brushgenerator, string algorithm)
Parameters not specified will resort to the DefaultXXX
-properties which can be specified when instantiating an IdenticonGenerator
; the IdenticonGenerator
's constructor is also rich in overloads:
public IdenticonGenerator()
public IdenticonGenerator(string algorithm)
public IdenticonGenerator(string algorithm, Size size)
public IdenticonGenerator(string algorithm, Size size, Color defaultBackgroundColor)
public IdenticonGenerator(string algorithm, Size size, Color defaultBackgroundColor, Size defaultBlocks)
public IdenticonGenerator(string algorithm, Size size, Color defaultBackgroundColor, Size defaultBlocks, Encoding encoding)
public IdenticonGenerator(string algorithm, Size size, Color defaultBackgroundColor, Size defaultBlocks, Encoding encoding, IBlockGenerator[] blockgenerators)
public IdenticonGenerator(string algorithm, Size size, Color defaultBackgroundColor, Size defaultBlocks, Encoding encoding, IBlockGenerator[] blockgenerators, IBrushGenerator brushgenerator)
(Ofcourse, the DefaultXXX
properties can be changed after instantiating an IdenticonGenerator
as well)
This allows you to specify defaults only once (using the ctor) or for each generated Identicon (passing parameters to the Create()
methods. Another approach is to use the fluent syntax to set only the desired defaults without having to specify all other parameters in the ctor:
var g = new IdenticonGenerator()
.WithSize(96,96)
.WithBlocks(6,6)
.WithBlockGenerators(IdenticonGenerator.ExtendedBlockGeneratorsConfig);
Adhering to the SOLID principle, it is possible to create your own "BlockGenerators" and "BrushGenerators" by simply implementing their interfaces IBlockGenerator
and IBrushGenerator
. This way you can influence the shapes and colors of the Identicon. There are a few defaults provided as static members of the IdenticonGenerator
class; these are:
DefaultBlockGeneratorsConfig
which only draws rectanglesExtendedBlockGeneratorsConfig
which draws different kinds of shapes (triangles, pie-parts, rectangles and rotated rectangles)DefaultBrushGeneratorConfig
which chooses a "random" (based on the input value to make the process deterministic) color.
Some BlockGenerators and BrushGenerators are provided; the rest is up to you. The blockgenerators are associated with a weight
so that you can influence the probability of a blockgenerator to be chosen when the IdenticonGenerator
is selecting a blockgenerator for a specific block in the Identicon.
Notes
Do note that the
Create()
method and its overloads all return aBitmap
object; you have to take care of storing it, sending it to the browser or whatever you need to do. Also note that you might want toDispose()
the returned Identicon when no longer needed.Also note that NIdenticon will round the image-dimensions DOWN to the nearest available size when the dimensions aren't exactly divisible by the horizontal/vertical blocks. Dimensions where width/horizontalblocks and height/verticalblocks are a multiple of oneanother work best (for example: for a width of 400 px you can use 2, 4, and 8 horizontal blocks but 6 will result in an image with a width of 396).
You might want to 'salt' your values (per Identicon (e.g. 'user' or 'account' for example) or per application, domain etc.) to make the Identicons even harder to 'reverse engineer'. A simple
myIDGenerator.Create(user.Email + user.Salt)
for example will do.
Example
A simple Windows Forms application and sample ASP.Net MVC website is provided for you so you can explore the options and quickly see what the result will look like.
Below are some example images:
Result | Algorithm | Value | Blockgens | Background | Blocks | Brush |
---|---|---|---|---|---|---|
[](examples/ex00.png) | MD5 |
Identicon |
Default | White | 6x6 | Static |
[](examples/ex01.png) | MD5 |
Identicon |
Extended | White | 6x6 | Static |
[](examples/ex02.png) | SHA256 |
Identicon |
Extended | White | 6x6 | Static |
[](examples/ex03.png) | SHA512 |
Identicon |
Extended | White | 6x6 | Static |
[](examples/ex04.png) | MD5 |
RobIII |
Extended | Transparent | 6x6 | Random |
[](examples/ex05.png) | RipeMD160 |
RobIII |
Extended | Transparent | 6x6 | Random |
[](examples/ex06.png) | SHA1 |
RobIII |
Extended | Transparent | 6x6 | Random |
[](examples/ex07.png) | SHA256 |
RobIII |
Extended | Transparent | 6x6 | Random |
[](examples/ex08.png) | SHA384 |
RobIII |
Extended | Transparent | 6x6 | Random |
[](examples/ex09.png) | SHA512 |
RobIII |
Extended | Transparent | 6x6 | Random |
[](examples/ex10.png) | SHA256 |
192.168.1.1 |
Extended | Transparent | 6x6 | Static |
[](examples/ex11.png) | SHA256 |
192.168.1.2 |
Extended | Transparent | 6x6 | Static |
[](examples/ex12.png) | SHA256 |
192.168.1.1 |
Extended | Black | 6x6 | Static |
[](examples/ex13.png) | SHA256 |
192.168.1.2 |
Extended | Black | 6x6 | Static |
[](examples/ex14.png) | SHA1 |
Foobar |
Extended | Black | 6x6 | Static |
[](examples/ex15.png) | SHA1 |
FooBar |
Extended | Black | 6x6 | Static |
[](examples/ex16.png) | MD5 |
foo_bar |
Extended | Transparent | 4x4 | Static |
[](examples/ex17.png) | MD5 |
foo_bar |
Extended | Transparent | 6x6 | Static |
[](examples/ex18.png) | MD5 |
foo_bar |
Extended | Transparent | 12x12 | Static |
[](examples/ex19.png) | MD5 |
foo_bar |
Default | Transparent | 4x6 | Static |
[](examples/ex20.png) | MD5 |
foo_bar |
Default | Transparent | 6x4 | Static |
[](examples/ex21.png) | SHA256 |
Identicon |
Extended | Transparent | 6x6 | Random |
[](examples/ex22.png) | SHA256 |
Identicon |
Extended | Transparent | 6x6 | Static |
[](examples/ex23.png) | SHA384 |
Identicon |
Custom(Triangles only) | Transparent | 6x6 | Random |
[](examples/ex24.png) | SHA384 |
Identicon |
Custom(Pie-slices only) | Transparent | 6x6 | Random |
[](examples/ex25.png) | SHA384 |
Identicon |
Custom(Rectangle + Pie in 4:1) | Transparent | 6x6 | Static |
Assembly Strong Naming & Usage in Signed Applications
This module produces strong named assemblies when compiled. When consumers of this package require strongly named assemblies, for example when they themselves are signed, the outputs should work as-is. The key file to create the strong name is adjacent to the csproj
file in the root of the source project. Please note that this does not increase security or provide tamper-proof binaries, as the key is available in the source code per Microsoft guidelines