RestImageResize/Security/Sha1HashGenerator.cs
/// <summary>
/// Computes a SHA1 hash for provided image transformation parameters.
/// </summary>
/// <param name="privateKey">Private key received from the image service administrator.</param>
/// <param name="width">Image width.</param>
/// <param name="height">Image height.</param>
/// <param name="transform">Image transformation mode.</param>
Computes a SHA1 hash for provided image transformation parameters.
Computes a SHA1 hash for provided image transformation parameters .
public string ComputeHash(string privateKey, int width, int height, ImageTransform transform)
        {
            var values = new[]
            {
                privateKey.ToLower(),
                width.ToString(),
                height.ToString(),
                transform.ToString().ToLower()
            };
            var bytes = Encoding.ASCII.GetBytes(string.Join(":", values));
            var sha1 = SHA1.Create();
            sha1.ComputeHash(bytes);
            return BitConverter.ToString(sha1.Hash).Replace("-", "").ToLower();
        }
public string ComputeHash ( string privateKey , int width , int height , ImageTransform transform ) { var values = new [ ] { privateKey . ToLower ( ) , width . ToString ( ) , height . ToString ( ) , transform . ToString ( ) . ToLower ( ) } ; var bytes = Encoding . ASCII . GetBytes ( string . Join ( " " , values ) ) ; var sha1 = SHA1 . Create ( ) ; sha1 . ComputeHash ( bytes ) ; return BitConverter . ToString ( sha1 . Hash ) . Replace ( " " , " " ) . ToLower ( ) ; }
Computes a SHA1 hash for provided image transformation parameters.
Computes a SHA1 hash for provided image transformation parameters .
privateKey
string
Private key received from the image service administrator.
Private key received from the image service administrator .
width
int
None
height
int
None
transform
ImageTransform
Image transformation mode.
Image transformation mode .