Encryption In Haskell | GitLocker.com Product

Encryption in Haskell

Last updated:

0 purchases

Encryption in Haskell Image
Encryption in Haskell Images
Encryption in Haskell Images
Encryption in Haskell Images
Encryption in Haskell Images

$5.00

Languages

Categories

Add to Cart

Description:

This Haskell code demonstrates various cryptographic techniques, including hashing and both symmetric (AES) and asymmetric (RSA) encryption. It utilizes the cryptonite library for cryptographic operations, showcasing how to securely hash data and encrypt/decrypt messages.

Key Components

  1. SHA-512 Hashing:
    • The createSHA512Hash function generates a SHA-512 hash of a given ByteString input using the Crypto.Hash module.
    • The resulting hash is converted to a hexadecimal string format using the convertToBase function with Base16.
  2. AES Encryption and Decryption:
    • The aesEncryptionDecryption function generates a random 256-bit AES key using getRandomBytes.
    • It encrypts the input data using AES in ECB mode with the encryptECB function.
    • The function returns the encrypted data along with the generated AES key.
  3. RSA Encryption and Decryption:
    • The rsaEncryptionDecryption function generates a pair of RSA keys (public and private) using the generate function from the Crypto.PubKey.RSA module.
    • It encrypts the input data with the public key using OAEP padding via the encryptOAEP function.
    • The function returns the encrypted data and the private key.
  4. Main Function:
    • The main function demonstrates the usage of the above functions.
    • It hashes a sample string ("Hello, World!") using SHA-512 and prints the result.
    • It encrypts a secret message ("Secret Message") using AES and prints the encrypted data and the AES key.
    • It also encrypts the same message using RSA and prints the encrypted data along with the private key.

Example Output

When executed, the program will produce output similar to the following:

javascript

 

SHA-512 Hash: <hashed_value>
Encrypted data (AES): <base64_encoded_encrypted_data>
AES Key: <base64_encoded_aes_key>
Encrypted data (RSA): <base64_encoded_encrypted_data>
Private Key (Base64): <base64_encoded_private_key>

This output demonstrates the successful execution of hashing and encryption processes, showcasing the functionality of the cryptographic techniques implemented.

Conclusion

This Haskell code effectively illustrates the use of cryptographic methods for securing data through hashing and encryption. It provides a clear example of how to implement SHA-512 hashing, AES symmetric encryption, and RSA asymmetric encryption using the cryptonite library. This code serves as a valuable reference for understanding basic cryptographic operations in Haskell.

Features:

  1. SHA-512 Hashing:
    • The createSHA512Hash function generates a SHA-512 hash of a given ByteString input using the Crypto.Hash module.
    • The resulting hash is converted to a hexadecimal string format using the convertToBase function with Base16.
  2. AES Encryption and Decryption:
    • The aesEncryptionDecryption function generates a random 256-bit AES key using getRandomBytes.
    • It encrypts the input data using AES in ECB mode with the encryptECB function.
    • The function returns the encrypted data along with the generated AES key.
  3. RSA Encryption and Decryption:
    • The rsaEncryptionDecryption function generates a pair of RSA keys (public and private) using the generate function from the Crypto.PubKey.RSA module.
    • It encrypts the input data with the public key using OAEP padding via the encryptOAEP function.
    • The function returns the encrypted data and the private key.
  4. Main Function:
    • The main function demonstrates the usage of the above functions.
    • It hashes a sample string ("Hello, World!") using SHA-512 and prints the result.
    • It encrypts a secret message ("Secret Message") using AES and prints the encrypted data and the AES key.
    • It also encrypts the same message using RSA and prints the encrypted data along with the private key.

Requirements:

Install the Haskell platform

Instructions:

Using the recommended IDE for Haskell should work just fine. 

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product: (if this is empty don't purchase this product)

Customer Reviews

There are no reviews.