Skip to content

Function: sha1() ​

sha1(message): Buffer

Compute the SHA-1 digest of a string, read as UTF-8. SHA-1 is broken for security: use it for checksums and compatibility, not for signatures.

Parameters ​

message ​

string

The text to hash; the empty string has a digest too.

Returns ​

Buffer

The 20-byte digest, as a Buffer: call .toString('hex') or .toString('base64') for its text form.

Example ​

typescript
import {sha1} from 'lakutata/utils'

console.log(sha1('hello').toString('hex'))
//aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d

Released under the MIT License.