{"id":15412260,"url":"https://github.com/robthree/nidenticon","last_synced_at":"2025-04-15T06:05:01.482Z","repository":{"id":13264279,"uuid":"15949540","full_name":"RobThree/NIdenticon","owner":"RobThree","description":"NIdenticon is a library for creating simple Identicons","archived":false,"fork":false,"pushed_at":"2022-11-01T16:00:20.000Z","size":604,"stargazers_count":98,"open_issues_count":0,"forks_count":12,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-15T06:04:55.060Z","etag":null,"topics":["avatar-generator","c-sharp","dotnet","identicon"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RobThree.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["RobThree"],"custom":["https://paypal.me/robiii"]}},"created_at":"2014-01-15T21:48:03.000Z","updated_at":"2025-04-10T09:17:18.000Z","dependencies_parsed_at":"2023-01-12T09:00:32.029Z","dependency_job_id":null,"html_url":"https://github.com/RobThree/NIdenticon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FNIdenticon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FNIdenticon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FNIdenticon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FNIdenticon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobThree","download_url":"https://codeload.github.com/RobThree/NIdenticon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249016622,"owners_count":21198833,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["avatar-generator","c-sharp","dotnet","identicon"],"created_at":"2024-10-01T16:52:00.128Z","updated_at":"2025-04-15T06:05:01.464Z","avatar_url":"https://github.com/RobThree.png","language":"C#","funding_links":["https://github.com/sponsors/RobThree","https://paypal.me/robiii"],"categories":[],"sub_categories":[],"readme":"![logo](nidenticonlogo.png) NIdenticon\r\n==========\r\n\r\n\u003e \"*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.*\"\r\n– [Wikipedia](http://en.wikipedia.org/wiki/Identicon)\r\n\r\nNIdenticon is a library (available as [NuGet package](https://www.nuget.org/packages/NIdenticon)) that helps creating simple Identicons but is flexible enough to allow for tweaking the output to your heart's content.\r\n\r\nThis project was inspired by:\r\n * [Github – Identicons!](https://github.com/blog/1586-identicons)\r\n * [David Hamp-Gonsalves – Generating Identicons](http://www.davidhampgonsalves.com/Identicons)\r\n * [Phil Haack – Identicons as Graphical Digital Fingerprints](http://haacked.com/archive/2007/01/22/Identicons_as_Visual_Fingerprints.aspx)\r\n * [Jeff Atwood – Identicons for .NET](http://www.codinghorror.com/blog/2007/01/identicons-for-net.html)\r\n\r\n## Usage\r\n\r\nThe most basic example is as follows:\r\n```c#\r\nvar g = new IdenticonGenerator();\r\nvar mybitmap = g.Create(\"foo\");\r\n````\r\n\r\nThis will create an Identicon based on the string `foo` with all other options default; another example is:\r\n```c#\r\nvar g = new IdenticonGenerator();\r\nvar mybitmap = g.Create(HttpContext.Current.Request.UserHostAddress);\r\n````\r\n\r\nThis creates an Identicon based on the IP-address of a remote host. The Identicon can be created with the following options:\r\n\r\n* Dimensions (width, height **default**: 400, 400)\r\n* Number of blocks, or \"pixels\" (horizontal, vertical **default**: 6, 6)\r\n* Hash algorithm (**default**: `SHA512`)\r\n* Background color (**default**: `Transparent`)\r\n* Even the default string-encoding used can be specified (**default**: UTF-8)\r\n\r\nThis library only contains one the `IdenticonGenerator` that has only one method: `Create()`, but which is rich in overloads. These are:\r\n```c#\r\nBitmap Create(byte[] value)\r\nBitmap Create(byte[] value, Size size)\r\nBitmap Create(byte[] value, Size size, Color backgroundcolor)\r\nBitmap Create(byte[] value, Size size, Color backgroundcolor, Size blocks)\r\nBitmap Create(byte[] value, Size size, Color backgroundcolor, Size blocks, IBlockGenerator[] blockgenerators)\r\nBitmap Create(byte[] value, Size size, Color backgroundcolor, Size blocks, IBlockGenerator[] blockgenerators, IBrushGenerator brushgenerator)\r\nBitmap Create(byte[] value, Size size, Color backgroundcolor, Size blocks, IBlockGenerator[] blockgenerators, IBrushGenerator brushgenerator, string algorithm)\r\nBitmap Create(IPAddress ipaddress)\r\nBitmap Create(IPAddress ipaddress, Size size)\r\nBitmap Create(IPAddress ipaddress, Size size, Color backgroundcolor)\r\nBitmap Create(IPAddress ipaddress, Size size, Color backgroundcolor, Size blocks)\r\nBitmap Create(IPAddress ipaddress, Size size, Color backgroundcolor, Size blocks, IBlockGenerator[] blockgenerators)\r\nBitmap Create(IPAddress ipaddress, Size size, Color backgroundcolor, Size blocks, IBlockGenerator[] blockgenerators, IBrushGenerator brushgenerator)\r\nBitmap Create(IPAddress ipaddress, Size size, Color backgroundcolor, Size blocks, IBlockGenerator[] blockgenerators, IBrushGenerator brushgenerator, string algorithm)\r\nBitmap Create(string value)\r\nBitmap Create(string value, Size size)\r\nBitmap Create(string value, Size size, Color backgroundcolor)\r\nBitmap Create(string value, Size size, Color backgroundcolor, Size blocks)\r\nBitmap Create(string value, Size size, Color backgroundcolor, Size blocks, Encoding encoding)\r\nBitmap Create(string value, Size size, Color backgroundcolor, Size blocks, Encoding encoding, IBlockGenerator[] blockgenerators)\r\nBitmap Create(string value, Size size, Color backgroundcolor, Size blocks, Encoding encoding, IBlockGenerator[] blockgenerators, IBrushGenerator brushgenerator)\r\nBitmap Create(string value, Size size, Color backgroundcolor, Size blocks, Encoding encoding, IBlockGenerator[] blockgenerators, IBrushGenerator brushgenerator, string algorithm)\r\n````\r\n\r\nParameters 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:\r\n```c#\r\npublic IdenticonGenerator()\r\npublic IdenticonGenerator(string algorithm)\r\npublic IdenticonGenerator(string algorithm, Size size)\r\npublic IdenticonGenerator(string algorithm, Size size, Color defaultBackgroundColor)\r\npublic IdenticonGenerator(string algorithm, Size size, Color defaultBackgroundColor, Size defaultBlocks)\r\npublic IdenticonGenerator(string algorithm, Size size, Color defaultBackgroundColor, Size defaultBlocks, Encoding encoding)\r\npublic IdenticonGenerator(string algorithm, Size size, Color defaultBackgroundColor, Size defaultBlocks, Encoding encoding, IBlockGenerator[] blockgenerators)\r\npublic IdenticonGenerator(string algorithm, Size size, Color defaultBackgroundColor, Size defaultBlocks, Encoding encoding, IBlockGenerator[] blockgenerators, IBrushGenerator brushgenerator)\r\n````\r\n\r\n\u003csub\u003e(Ofcourse, the `DefaultXXX` properties can be changed after instantiating an `IdenticonGenerator` as well)\u003c/sub\u003e\r\n\r\nThis 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:\r\n\r\n```c#\r\nvar g = new IdenticonGenerator()\r\n        .WithSize(96,96)\r\n        .WithBlocks(6,6)\r\n        .WithBlockGenerators(IdenticonGenerator.ExtendedBlockGeneratorsConfig);\r\n````\r\n\r\nAdhering 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:\r\n\r\n* `DefaultBlockGeneratorsConfig` which only draws rectangles\r\n* `ExtendedBlockGeneratorsConfig` which draws different kinds of shapes (triangles, pie-parts, rectangles and rotated rectangles)\r\n* `DefaultBrushGeneratorConfig` which chooses a \"random\" (based on the input value to make the process deterministic) color.\r\n \r\nSome 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.\r\n\r\n#Notes\r\n\r\n1. Do note that the `Create()` method and its overloads all return a `Bitmap` 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 to `Dispose()` the returned Identicon when no longer needed.\r\n\r\n2. 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).\r\n\r\n3. 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.\r\n\r\n# Example\r\n\r\nA 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.\r\n\r\nBelow are some example images:\r\n\r\nResult | Algorithm | Value | Blockgens | Background | Blocks | Brush\r\n--- | --- | --- | --- | --- | --- | ---\r\n![](examples/ex00.png) | `MD5` | `Identicon` | Default | White | 6x6 | Static\r\n![](examples/ex01.png) | `MD5` | `Identicon` | Extended | White | 6x6 | Static\r\n![](examples/ex02.png) | `SHA256` | `Identicon` | Extended | White | 6x6 | Static\r\n![](examples/ex03.png) | `SHA512` | `Identicon` | Extended | White | 6x6 | Static\r\n![](examples/ex04.png) | `MD5` | `RobIII` | Extended | Transparent | 6x6 | Random\r\n![](examples/ex05.png) | `RipeMD160` | `RobIII` | Extended | Transparent | 6x6 | Random\r\n![](examples/ex06.png) | `SHA1` | `RobIII` | Extended | Transparent | 6x6 | Random\r\n![](examples/ex07.png) | `SHA256` | `RobIII` | Extended | Transparent | 6x6 | Random\r\n![](examples/ex08.png) | `SHA384` | `RobIII` | Extended | Transparent | 6x6 | Random\r\n![](examples/ex09.png) | `SHA512` | `RobIII` | Extended | Transparent | 6x6 | Random\r\n![](examples/ex10.png) | `SHA256` | `192.168.1.1` | Extended | Transparent | 6x6 | Static\r\n![](examples/ex11.png) | `SHA256` | `192.168.1.2` | Extended | Transparent | 6x6 | Static\r\n![](examples/ex12.png) | `SHA256` | `192.168.1.1` | Extended | Black | 6x6 | Static\r\n![](examples/ex13.png) | `SHA256` | `192.168.1.2` | Extended | Black | 6x6 | Static\r\n![](examples/ex14.png) | `SHA1` | `Foobar` | Extended | Black | 6x6 | Static\r\n![](examples/ex15.png) | `SHA1` | `FooBar` | Extended | Black | 6x6 | Static\r\n![](examples/ex16.png) | `MD5` | `foo_bar` | Extended | Transparent | 4x4 | Static\r\n![](examples/ex17.png) | `MD5` | `foo_bar` | Extended | Transparent | 6x6 | Static\r\n![](examples/ex18.png) | `MD5` | `foo_bar` | Extended | Transparent | 12x12 | Static\r\n![](examples/ex19.png) | `MD5` | `foo_bar` | Default | Transparent | 4x6 | Static\r\n![](examples/ex20.png) | `MD5` | `foo_bar` | Default | Transparent | 6x4 | Static\r\n![](examples/ex21.png) | `SHA256` | `Identicon` | Extended | Transparent | 6x6 | Random\r\n![](examples/ex22.png) | `SHA256` | `Identicon` | Extended | Transparent | 6x6 | Static\r\n![](examples/ex23.png) | `SHA384` | `Identicon` | Custom\u003cbr\u003e\u003csub\u003e(Triangles only)\u003c/sub\u003e | Transparent | 6x6 | Random\r\n![](examples/ex24.png) | `SHA384` | `Identicon` | Custom\u003cbr\u003e\u003csub\u003e(Pie-slices only)\u003c/sub\u003e | Transparent | 6x6 | Random\r\n![](examples/ex25.png) | `SHA384` | `Identicon` | Custom\u003cbr\u003e\u003csub\u003e(Rectangle + Pie in 4:1)\u003c/sub\u003e | Transparent | 6x6 | Static\r\n\r\n# Assembly Strong Naming \u0026 Usage in Signed Applications\r\n\r\nThis 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](https://msdn.microsoft.com/en-us/library/wd40t7ad(v=vs.110).aspx)\r\n\r\n[![Build status](https://ci.appveyor.com/api/projects/status/l77y1dgplt58k4ao)](https://ci.appveyor.com/project/RobIII/nidenticon) \u003ca href=\"https://www.nuget.org/packages/NIdenticon/\"\u003e\u003cimg src=\"http://img.shields.io/nuget/v/NIdenticon.svg?style=flat-square\" alt=\"NuGet version\" height=\"18\"\u003e\u003c/a\u003e\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobthree%2Fnidenticon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobthree%2Fnidenticon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobthree%2Fnidenticon/lists"}