```{index} single: hashsize; Digest::SHA function ``` ```{index} single: Digest::SHA::hashsize; Perl function ``` # hashsize Return the digest length of a `Digest::SHA` object in bits. For a given algorithm the hashsize is a constant: 160 for SHA-1, 224 for SHA-224, 256 for SHA-256 and SHA-512/256, 384 for SHA-384, 512 for SHA-512. Divide by 8 to get the byte length of the output from `digest`. ## Synopsis ```perl my $bits = $sha->hashsize; ``` ## What you get back An integer, always a multiple of 8. ## Examples ```perl my $sha = Digest::SHA->new(256); print $sha->hashsize; # 256 print $sha->hashsize / 8; # 32 (bytes per digest) ``` ```perl my $sha = Digest::SHA->new("SHA-512/224"); print $sha->hashsize; # 224 ``` ```perl ## Preallocate output buffer for $sha->digest: my $buf = "\0" x ($sha->hashsize / 8); ``` ## Edge cases - Called on a non-`Digest::SHA` object, returns `undef`. ## Differences from upstream Fully compatible with upstream `Digest::SHA` {{ upstream.Digest_SHA }}. ## See also - `algorithm` — the integer algorithm code for this object. - `digest` — output whose length is `hashsize / 8` bytes.