Go Encryption | GitLocker.com Product

Go Encryption

Last updated:

0 purchases

Go Encryption Image
Go Encryption Images
Go Encryption Images
Go Encryption Images

$5.00

Languages

Categories

Go Google GoLang
Add to Cart

Description:

This Go code demonstrates various cryptographic techniques, including hashing and both symmetric (AES) and asymmetric (RSA) encryption. It utilizes the Go standard library's crypto package to perform these operations securely.

Key Components

  1. SHA-512 Hashing:
    • The createSHA512Hash function generates a SHA-512 hash of a given string input using the sha512 package.
    • The resulting hash is formatted as a hexadecimal string for easy readability.
  2. AES Encryption and Decryption:
    • The aesEncryptionDecryption function generates a random 256-bit AES key using the rand package.
    • It encrypts the input data using AES in CBC mode. The function creates an initialization vector (IV) for the encryption process to enhance security.
    • The function returns the encrypted data encoded in base64 format along with the base64-encoded AES key.
  3. RSA Encryption and Decryption:
    • The rsaEncryptionDecryption function generates a pair of RSA keys (public and private) using the rsa package.
    • It encrypts the input data with the public key using OAEP padding, which provides additional security.
    • The function returns the encrypted data in base64 format and the private key exported as a PEM-encoded string.
  4. Exporting RSA Private Key:
    • The exportPrivateKeyAsPEM function converts the RSA private key into a PEM format, making it suitable for storage and transmission.
  5. 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 PEM-encoded 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 (PEM):
-----BEGIN PRIVATE KEY-----
<base64_encoded_private_key>
-----END PRIVATE KEY-----

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

Conclusion

This Go 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 Go standard library. This code serves as a valuable reference for understanding basic cryptographic operations in Go.

Features:

  1. SHA-512 Hashing:
    • The createSHA512Hash function generates a SHA-512 hash of a given string input using the sha512 package.
    • The resulting hash is formatted as a hexadecimal string for easy readability.
  2. AES Encryption and Decryption:
    • The aesEncryptionDecryption function generates a random 256-bit AES key using the rand package.
    • It encrypts the input data using AES in CBC mode. The function creates an initialization vector (IV) for the encryption process to enhance security.
    • The function returns the encrypted data encoded in base64 format along with the base64-encoded AES key.
  3. RSA Encryption and Decryption:
    • The rsaEncryptionDecryption function generates a pair of RSA keys (public and private) using the rsa package.
    • It encrypts the input data with the public key using OAEP padding, which provides additional security.
    • The function returns the encrypted data in base64 format and the private key exported as a PEM-encoded string.
  4. Exporting RSA Private Key:
    • The exportPrivateKeyAsPEM function converts the RSA private key into a PEM format, making it suitable for storage and transmission.
  5. 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 PEM-encoded private key.

Requirements:

Latest release of GoLang installed. 

Instructions:

For best results, use Visual Studio Code and appropriate extensions.

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.