SHA1 hash generator
This tool helps you to generate SHA1 code, you can input a string to generate SHA1 code
What is SHA1?
In cryptography, SHA-1 (Secure Hash Algorithm 1) is a cryptographically broken but still widely used hash function which takes an input and produces a 160-bit (20-byte) hash value known as a message digest – typically rendered as a hexadecimal number, 40 digits long. It was designed by the United States National Security Agency, and is a U.S. Federal Information Processing Standard.
Since 2005, SHA-1 has not been considered secure against well-funded opponents; as of 2010 many organizations have recommended its replacement.
NIST formally deprecated use of SHA-1 in 2011 and disallowed its use for digital signatures in 2013. As of 2020, chosen-prefix attacks against SHA-1 are practical.
As such, it is recommended to remove SHA-1 from products as soon as possible and instead use SHA-2 or SHA-3. Replacing SHA-1 is urgent where it is used for digital signatures.
All major web browser vendors ceased acceptance of SHA-1 SSL certificates in 2017.
In February 2017, CWI Amsterdam and Google announced they had performed a collision attack against SHA-1, publishing two dissimilar PDF files which produced the same SHA-1 hash. However, SHA-1 is still secure for HMAC. Microsoft has discontinued SHA-1 code signing support for Windows Update on August 7, 2020.
https://en.wikipedia.org/wiki/SHA-1
Nodejs
const crypto = require('crypto');
const hash = crypto.createHash('sha1');
const data = 'My string to hash';
hash.update(data);
const digest = hash.digest('hex');
console.log(digest);
Php
<?php
$string = 'My string to hash';
echo sha1($string);
?>
JAVA
import java.security.MessageDigest;
public class SHA1Example {
public static void main(String[] args) throws Exception {
String stringToHash = "My string to hash";
MessageDigest digest = MessageDigest.getInstance("SHA-1");
byte[] bytes = digest.digest(stringToHash.getBytes());
StringBuilder builder = new StringBuilder();
for (byte b : bytes) {
builder.append(String.format("%02x", b));
}
System.out.println(builder.toString());
}
}
C#
using System.Security.Cryptography;
public class SHA1Example {
public static void Main() {
string stringToHash = "My string to hash";
SHA1 sha1 = new SHA1CryptoServiceProvider();
byte[] bytes = sha1.ComputeHash(Encoding.UTF8.GetBytes(stringToHash));
StringBuilder builder = new StringBuilder();
foreach (byte b in bytes) {
builder.Append(b.ToString("x2"));
}
Console.WriteLine(builder.ToString());
}
}
Python
import hashlib
string_to_hash = "My string to hash"
hash_sha1 = hashlib.sha1(string_to_hash.encode())
hex_digest = hash_sha1.hexdigest()
print(hex_digest)
Go lang
package main
import (
"crypto/sha1"
"fmt"
)
func main() {
stringToHash := "My string to hash"
sha1Hash := sha1.New()
sha1Hash.Write([]byte(stringToHash))
digest := sha1Hash.Sum(nil)
fmt.Printf("%x\n", digest)
}
Dart lang
import 'dart:convert';
import 'dart:typed_data';
import 'package:crypto/crypto.dart';
void main() {
String stringToHash = "My string to hash";
var sha1Hash = sha1.convert(Utf8Encoder().convert(stringToHash));
print(sha1Hash.toString());
}