Click or drag to resize

IdenticonFromValue Method

Generates a hash for a specified value and creates an Identicon instance from the generated hash.

Namespace:  Jdenticon
Assembly:  Jdenticon.dll
Syntax
public static Identicon FromValue(
	Object value,
	int size,
	string hashAlgorithmName = "SHA1"
)

Parameters

value
Type: SystemObject
Value that will be converted to a string and then hashed. Null values are supported and handled as empty strings.
size
Type: SystemInt32
The size of the icon in pixels (the icon is quadratic).
hashAlgorithmName (Optional)
Type: SystemString
The name of the hash algorithm to be used for hashing.

Return Value

Type: Identicon
An Identicon instance for the hash of value.
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptionsize is less than 1 pixel.
ArgumentExceptionThe specified hashAlgorithmName is not supported.
Remarks

This method will use ToString to generate a string representation of value and then hash the UTF8 representation of the string using the specified algorithm. If value is null an empty byte array is hashed.

Security note Security Note

Avoid using sensitive information as base for an icon, especially in combination with a weak hash algorithm like MD5 and SHA1. Consider using public information instead, like an id or a user name.

Hash algorithms available as hashAlgorithmName depends on the platform. The table below lists the possible values and on what platforms they are supported.

Hash algorithm.NET Standard 1.0.NET Standard 1.3.NET Framework
MD5YesYesYes
SHA1YesYesYes
SHA256-YesYes
SHA384-YesYes
SHA512-YesYes
See Also