
- Cryptography Tutorial
- Cryptography - Home
- Cryptography - Origin
- Cryptography - History
- Cryptography - Principles
- Cryptography - Applications
- Cryptography - Benefits & Drawbacks
- Cryptography - Modern Age
- Cryptography - Traditional Ciphers
- Cryptography - Need for Encryption
- Cryptography - Double Strength Encryption
- Cryptosystems
- Cryptosystems
- Cryptosystems - Components
- Attacks On Cryptosystem
- Cryptosystems - Rainbow table attack
- Cryptosystems - Dictionary attack
- Cryptosystems - Brute force attack
- Cryptosystems - Cryptanalysis Techniques
- Types of Cryptography
- Cryptosystems - Types
- Public Key Encryption
- Modern Symmetric Key Encryption
- Cryptography Hash functions
- Key Management
- Cryptosystems - Key Generation
- Cryptosystems - Key Storage
- Cryptosystems - Key Distribution
- Cryptosystems - Key Revocation
- Block Ciphers
- Cryptosystems - Stream Cipher
- Cryptography - Block Cipher
- Cryptography - Feistel Block Cipher
- Block Cipher Modes of Operation
- Block Cipher Modes of Operation
- Electronic Code Book (ECB) Mode
- Cipher Block Chaining (CBC) Mode
- Cipher Feedback (CFB) Mode
- Output Feedback (OFB) Mode
- Counter (CTR) Mode
- Classic Ciphers
- Cryptography - Reverse Cipher
- Cryptography - Caesar Cipher
- Cryptography - ROT13 Algorithm
- Cryptography - Transposition Cipher
- Cryptography - Encryption Transposition Cipher
- Cryptography - Decryption Transposition Cipher
- Cryptography - Multiplicative Cipher
- Cryptography - Affine Ciphers
- Cryptography - Simple Substitution Cipher
- Cryptography - Encryption of Simple Substitution Cipher
- Cryptography - Decryption of Simple Substitution Cipher
- Cryptography - Vigenere Cipher
- Cryptography - Implementing Vigenere Cipher
- Modern Ciphers
- Base64 Encoding & Decoding
- Cryptography - XOR Encryption
- Substitution techniques
- Cryptography - MonoAlphabetic Cipher
- Cryptography - Hacking Monoalphabetic Cipher
- Cryptography - Polyalphabetic Cipher
- Cryptography - Playfair Cipher
- Cryptography - Hill Cipher
- Polyalphabetic Ciphers
- Cryptography - One-Time Pad Cipher
- Implementation of One Time Pad Cipher
- Cryptography - Transposition Techniques
- Cryptography - Rail Fence Cipher
- Cryptography - Columnar Transposition
- Cryptography - Steganography
- Symmetric Algorithms
- Cryptography - Data Encryption
- Cryptography - Encryption Algorithms
- Cryptography - Data Encryption Standard
- Cryptography - Triple DES
- Cryptography - Double DES
- Advanced Encryption Standard
- Cryptography - AES Structure
- Cryptography - AES Transformation Function
- Cryptography - Substitute Bytes Transformation
- Cryptography - ShiftRows Transformation
- Cryptography - MixColumns Transformation
- Cryptography - AddRoundKey Transformation
- Cryptography - AES Key Expansion Algorithm
- Cryptography - Blowfish Algorithm
- Cryptography - SHA Algorithm
- Cryptography - RC4 Algorithm
- Cryptography - Camellia Encryption Algorithm
- Cryptography - ChaCha20 Encryption Algorithm
- Cryptography - CAST5 Encryption Algorithm
- Cryptography - SEED Encryption Algorithm
- Cryptography - SM4 Encryption Algorithm
- IDEA - International Data Encryption Algorithm
- Public Key (Asymmetric) Cryptography Algorithms
- Cryptography - RSA Algorithm
- Cryptography - RSA Encryption
- Cryptography - RSA Decryption
- Cryptography - Creating RSA Keys
- Cryptography - Hacking RSA Cipher
- Cryptography - ECDSA Algorithm
- Cryptography - DSA Algorithm
- Cryptography - Diffie-Hellman Algorithm
- Data Integrity in Cryptography
- Data Integrity in Cryptography
- Message Authentication
- Cryptography Digital signatures
- Public Key Infrastructure
- Hashing
- MD5 (Message Digest Algorithm 5)
- SHA-1 (Secure Hash Algorithm 1)
- SHA-256 (Secure Hash Algorithm 256-bit)
- SHA-512 (Secure Hash Algorithm 512-bit)
- SHA-3 (Secure Hash Algorithm 3)
- Hashing Passwords
- Bcrypt Hashing Module
- Modern Cryptography
- Quantum Cryptography
- Post-Quantum Cryptography
- Cryptographic Protocols
- Cryptography - SSL/TLS Protocol
- Cryptography - SSH Protocol
- Cryptography - IPsec Protocol
- Cryptography - PGP Protocol
- Image & File Cryptography
- Cryptography - Image
- Cryptography - File
- Steganography - Image
- File Encryption and Decryption
- Cryptography - Encryption of files
- Cryptography - Decryption of files
- Cryptography in IoT
- IoT security challenges, Threats and Attacks
- Cryptographic Techniques for IoT Security
- Communication Protocols for IoT Devices
- Commonly Used Cryptography Techniques
- Custom Building Cryptography Algorithms (Hybrid Cryptography)
- Cloud Cryptography
- Quantum Cryptography
- Image Steganography in Cryptography
- DNA Cryptography
- One Time Password (OTP) algorithm in Cryptography
- Difference Between
- Cryptography - MD5 vs SHA1
- Cryptography - RSA vs DSA
- Cryptography - RSA vs Diffie-Hellman
- Cryptography vs Cryptology
- Cryptography - Cryptology vs Cryptanalysis
- Cryptography - Classical vs Quantum
- Cryptography vs Steganography
- Cryptography vs Encryption
- Cryptography vs Cyber Security
- Cryptography - Stream Cipher vs Block Cipher
- Cryptography - AES vs DES ciphers
- Cryptography - Symmetric vs Asymmetric
- Cryptography Useful Resources
- Cryptography - Quick Guide
- Cryptography - Discussion
SHA−512 (Secure Hash Algorithm 512-bit)
SHA-512, or Secure Hash method 512, is a hashing technique that converts text of arbitrary length into a fixed-size string. Each output has a SHA-512 length of 512 bits (64 bytes).
This algorithm is frequently used for email address hashing, password hashing, and digital record verification. SHA-512 is also used in blockchain technology, with the BitShares network becoming the most known example.
In this chapter we will look at the origins of SHA-512 and how it works with the application of this algorithm.
What is SHA-512?
SHA-512 generates a hash value of 512 bits (64 bytes), making it one of the largest hash functions in the SHA-2 family. SHA-512, like all cryptographic hash algorithms, has the following basic properties −
- Deterministic − The same input will always get the same result.
- Fast to compute − The hash for any given data can be calculated very quickly.
- Irreversible − You can not determine the original input from its hash.
- Collision-resistant − It is computationally challenging to discover two distinct inputs that generate the same hash.
- Avalanche effect − A small change in input (even flipping a single bit) results in a significantly different hash.
How SHA-512 Works?
Without going too far into the mathematical concepts, SHA-512 operates as follows −
- Initialization − It starts with eight hash values calculated from the square roots of the initial eight prime numbers.
- Pre-processing − The input message is padded so that it is a multiple of the Block size. The original message's 128-bit length (before padding) is added to the very end of the padded message.
- Parsing − The message is then separated into 1024-bit parts.
- Main Loop − The main loop analyses each 1024-bit block in 80 rounds, manipulating the data via logical operations, bitwise shifts, and modular arithmetic.
- Output − After all of the blocks have been processed, the resulting 512-bit message digest is output as the hash.
Algorithm
The SHA-512 algorithm consists of the following steps −
- Message Padding − First, your message is padded to ensure that it is the correct size for the algorithm. This ensures that it can be broken down into blocks and processed.
- Initial hash values − The algorithm starts with eight initial hash values. These set values serve as the basis for the hashing procedure.
- Message processing − The padded message is divided into blocks. Each block progresses over a series of stages known as rounds. In each round, the block is mixed and adjusted using specific techniques.
- Final hash value − After all blocks have been examined, the hash value is computed. This hash value serves as a unique fingerprint for the original message.
- Output − The SHA-512 algorithm generates the final hash result, which is generally a string of hexadecimal integers. This is the value returned after hashing your original message.

Implementation of SHA-512
Now we will implement the SHA-512 algorithm using different programming language.
Using Python
As we have seen the implementation of SHA-1 and SHA-256 in the previous chapters just like those implementations we will implement this algorithm but there is a slight change in the function we have used to generate a new hash object. So we will use hashlib.sha512() in this code.
import hashlib # generate a string to hash my_string = "Hello, Tutorialspoint family!" # chaneg the string to bytes my_bytes = my_string.encode('utf-8') # generate a new SHA-512 hash object hash_object = hashlib.sha512() # Update the hash object hash_object.update(my_bytes) # get the hexadecimal representation hash_hex = hash_object.hexdigest() # print the SHA-512 hash print("SHA-512 hash of", my_string, ":", hash_hex)
Output
SHA-512 hash of Hello, Tutorialspoint family! : 7adcec675a2bae322d62c0266d148fbd9fcd65a8d9707c2e44f2ebc8138d4facf97b1079db71d9ff9e484fdcd1dd869b1c24086f3e58c6697e9db88074a2f831
Using Java
Now we will implement SHA-512 using Java and its built-in class MessageDigest and NoSuchAlgorithmException. With MessageDigest class of java we can provide cryptographic functionalities and use 'computeSHA512()' method which takes a message as input and computes its SHA-512 hash value. And NoSuchAlgorithmException class is used to throw an exception if there no such algorithm is found. So the code for SHA-512 using Java is as follows −
import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class SHA512Example { // Function to compute SHA-512 hash public static String computeSHA512(String message) throws NoSuchAlgorithmException { // Create a MessageDigest object for SHA-512 MessageDigest digest = MessageDigest.getInstance("SHA-512"); // Update the digest with the message bytes byte[] hashedBytes = digest.digest(message.getBytes()); // Convert hashed bytes to hexadecimal representation StringBuilder hexString = new StringBuilder(); for (byte b : hashedBytes) { String hex = Integer.toHexString(0xff & b); if (hex.length() == 1) hexString.append('0'); hexString.append(hex); } // Return the hexadecimal representation return hexString.toString(); } public static void main(String[] args) { String message = "Namaste, Tutorialspoint Family!"; try { String hashedMessage = computeSHA512(message); System.out.println("SHA-512 Hash of '" + message + "' is: " + hashedMessage); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } } }
Input/Output
SHA-512 Hash of 'Namaste, Tutorialspoint Family!' is: 140b8ea03714699c3738071bff5446587a8cf8ecfa092ed0f49115ee8ad9617055fcfc99a484e8e16987b9a7241a8314b1a85c8e49b7c8cb2de1e276cb2a3290
Applications
SHA-512 and its siblings from the SHA-2 family are commonly used in a number of security applications and protocols, including −
- Digital signatures are used to validate the integrity of a message or document.
- Certificate creation is a process used by Certificate Authorities (CAs) to assure the security of digital certificates.
- Password hashing involves storing passwords in databases as hashes rather than plain text.
- Blockchain and cryptocurrencies: Used to ensure data integrity and security.