This online SHA-2 hash code generator tool will generate SHA-2 (SHA-256, SHA-512, SHA-384) hash codes for any given string. Also get the source code for SHA-2 hash code generator in C#.Net, Java and PHP.
This sha hash generator tool generates SHA-2 hash codes from the entered text. I've provided three commonly used SHA-2 hashing algorithms SHA-256, SHA-512 and SHA-384. SHA-256 calculator (or) converter is the widely used sha-2 hash code generator compared to the SHA-512 calculator or SHA-384 calculator.
SHA-2 is is the 2nd version of sha hash generator algorithm. It is otherwise called as Secure Hash Algorithm 2. SHA-2 is a set of 6 hashing algorithm (SHA-256, SHA-512, SHA-224, SHA-384, SHA-512/224, SHA-512/256). The term SHA-2 is misrepresented for SHA-256. Don't get confused when someone asks you for SHA-2 hash code. Actually they are asking for SHA-256.
Major programming languages has inbuilt SHA-256 classes to generate and verify SHA-256 hash codes.
.Net has System.Security.Cryptography.SHA256 abstract class. This class has ComputeHash(Byte[]), ComputeHash(Stream) and ComputeHash(Byte[], Int32, Int32) methods which can be used to generate SHA-256 hash codes.
A simple .Net C# class method which takes a string as input and returns SHA-256 hash code.
// SHA-256 Hash Code Generator Method public static string SHA256Generator(string strInput) { SHA256 sha256 = new SHA256CryptoServiceProvider(); //provide the string in byte format to the ComputeHash method. //This method returns the SHA-256 hash code in byte array byte[] arrHash = sha256.ComputeHash(Encoding.UTF8.GetBytes(strInput)); // use a Stringbuilder to append the bytes from the array to create a SHA-256 hash code string. StringBuilder sbHash = new StringBuilder(); // Loop through byte array of the hashed code and format each byte as a hexadecimal code. for (int i = 0; i < arrHash.Length; i++) { sbHash.Append(arrHash[i].ToString("x2")); } // Return the hexadecimal SHA-256 hash code string. return sbHash.ToString(); }
In Java you can use the MessageDigest abstract class to generate the SHA-256 hash code for a string
A simple java class method which takes a string as input and returns SHA-256 hash code.
import java.math.BigInteger; import java.security.MessageDigest; public class SHA256 { public static String GenerateHash(String input) { MessageDigest objSHA = MessageDigest.getInstance("SHA-256"); byte[] bytSHA = objSHA.digest(input.getBytes()); BigInteger intNumber = new BigInteger(1, bytSHA); String strHashCode = intNumber.toString(16); // pad with 0 if the hexa digits are less then 64. while (strHashCode.length() < 64) { strHashCode = "0" + strHashCode; } return strHashCode; } }
PHP has hash() function to calculate SHA-256 hash code.
<?php echo hash('sha256', 'www.MyTecBits.com'); ?>
Major programming languages has inbuilt SHA-512 classes to generate and verify SHA-512 hash codes.
.Net has System.Security.Cryptography.SHA512 abstract class. This class has ComputeHash(Byte[]), ComputeHash(Stream) and ComputeHash(Byte[], Int32, Int32) methods which can be used to generate SHA-512 hash codes.
A simple .Net C# class method which takes a string as input and returns SHA-512 hash code.
// SHA-512 Hash Code Generator Method public static string SHA512Generator(string strInput) { SHA512 sha512 = new SHA512CryptoServiceProvider(); //provide the string in byte format to the ComputeHash method. //This method returns the SHA-512 hash code in byte array byte[] arrHash = sha512.ComputeHash(Encoding.UTF8.GetBytes(strInput)); // use a Stringbuilder to append the bytes from the array to create a SHA-512 hash code string. StringBuilder sbHash = new StringBuilder(); // Loop through byte array of the hashed code and format each byte as a hexadecimal code. for (int i = 0; i < arrHash.Length; i++) { sbHash.Append(arrHash[i].ToString("x2")); } // Return the hexadecimal SHA-512 hash code string. return sbHash.ToString(); }
In Java you can use the MessageDigest abstract class to generate the SHA-512 hash code for a string
A simple java class method which takes a string as input and returns SHA-512 hash code.
import java.math.BigInteger; import java.security.MessageDigest; public class 512 { public static String GenerateHash(String input) { MessageDigest objSHA = MessageDigest.getInstance("SHA-512"); byte[] bytSHA = objSHA.digest(input.getBytes()); BigInteger intNumber = new BigInteger(1, bytSHA); String strHashCode = intNumber.toString(16); // pad with 0 if the hexa digits are less then 128. while (strHashCode.length() < 128) { strHashCode = "0" + strHashCode; } return strHashCode; } }
PHP has hash() function to calculate SHA-512 hash code.
<?php echo hash('sha512', 'www.MyTecBits.com'); ?>
Major programming languages has inbuilt SHA-384 classes to generate and verify SHA-384 hash codes.
.Net has System.Security.Cryptography.SHA384 abstract class. This class has ComputeHash(Byte[]), ComputeHash(Stream) and ComputeHash(Byte[], Int32, Int32) methods which can be used to generate SHA-384 hash codes.
A simple .Net C# class method which takes a string as input and returns SHA-384 hash code.
// SHA-384 Hash Code Generator Method public static string SHA384Generator(string strInput) { SHA384 sha384 = new SHA384CryptoServiceProvider(); //provide the string in byte format to the ComputeHash method. //This method returns the SHA-384 hash code in byte array byte[] arrHash = sha384.ComputeHash(Encoding.UTF8.GetBytes(strInput)); // use a Stringbuilder to append the bytes from the array to create a SHA-384 hash code string. StringBuilder sbHash = new StringBuilder(); // Loop through byte array of the hashed code and format each byte as a hexadecimal code. for (int i = 0; i < arrHash.Length; i++) { sbHash.Append(arrHash[i].ToString("x2")); } // Return the hexadecimal SHA-384 hash code string. return sbHash.ToString(); }
In Java you can use the MessageDigest abstract class to generate the SHA-384 hash code for a string
A simple java class method which takes a string as input and returns SHA-384 hash code.
import java.math.BigInteger; import java.security.MessageDigest; public class SHA384 { public static String GenerateHash(String input) { MessageDigest objSHA = MessageDigest.getInstance("SHA-384"); byte[] bytSHA = objSHA.digest(input.getBytes()); BigInteger intNumber = new BigInteger(1, bytSHA); String strHashCode = intNumber.toString(16); // pad with 0 if the hexa digits are less then 96. while (strHashCode.length() < 96) { strHashCode = "0" + strHashCode; } return strHashCode; } }
PHP has hash() function to calculate SHA-384 hash code.
<?php echo hash('sha384', 'www.MyTecBits.com'); ?>
Page Last Modified On: Jul 23, 2021
Disclaimer: We took every effort to provide higher level of accuracy in the calculators, converters and tools we have added to www.MyTecBits.com Tools section. But, we cannot give any guarantee or can be held responsible for any errors, defects, faults or mistakes in any of the calculators, converters or tools. Please see detailed terms of use and liability disclaimer in Terms of Use Page.