You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.9 KiB

Utility for Project Coconut Server/Desktop

CI codecov

log package

Contains simple wrapper methods to support level-based logging.

Usage

import "github.com/jaeha-choi/Proj_Coconut_Utility/log"

// Initialize logger
log.Init(os.Stdout, log.Error) 

log.Debug("Debug msg") // Won't print; Mode is set to log.Error
log.Error(err)

util package

Contains utility methods for sending/receiving packets and defined status codes.

cryptography package

Note: I am not a cryptographer. Use this package at your own risk. If you notice any security issue, please email me.

Provide functions to encrypt/decrypt large files in chunks using AES-GCM and RSA.

Usage

  • Encryption (AES-GCM + RSA):
... 
streamEncrypt, err := cryptography.EncryptSetup(testFileN)
// Error handling
err = streamEncrypt.Encrypt(writer, client1PublicKey, client2PrivKey)
// Error handling
err := streamEncrypt.Close()
...
  • Decryption (AES-GCM + RSA):
...
streamDecrypt, err := cryptography.DecryptSetup()
// Error handling
err = streamDecrypt.Decrypt(reader, client2PublicKey, client1PrivKey)
// Error handling
err := streamDecrypt.Close()
...
  • Encryption (RSA):
cryptography.EncryptSignMsg(msg, client1PublicKey, client2PrivKey)
  • Decryption (RSA):
cryptography.DecryptVerifyMsg(encryptedMsg, client2PublicKey, client1PrivKey)
  • Open RSA PEM blocks:
pubPem, privPem, err := OpenKeys("./path/to/keys/")
  • PEM blocks to PrivateKey struct:
privKey, err := PemToKeys(privPem)

privKey             // Private key
privKey.PublicKey   // Public key