Skip to content

Cryptographic Accelerator

BastouP411 edited this page Feb 12, 2021 · 3 revisions

This peripheral provides cryptography functions (encryption, hash, and key generation) to be used.

Cryptographic Accelerator

Crafting

To be crafted the Cryptographic Accelerator requires:

  • 6 stone blocks
  • 1 redstone
  • 2 gold ingots

Shaped crafting recipe

Methods

The wraped peripheral will be named crypto

crypto.encodeBase64(data: string): string

This encodes the data string using base64.

crypto.decodeBase64(base64: string): string

This decodes the base64 string encoded using base64.

crypto.randomBytes(length: number): string

This generates a random string with a length of length It may be used to generate keys for the AES encryption or hmacs.

crypto.encryptAES(data: string, key: string, iv: string): string

This encrypts the data string using the AES-CBC algorithm. The key must be 16, 24 or 32 bytes long and the iv must be 16 bytes long. Both of them may be generated using the randomBytes method.

crypto.decryptAES(data: string, key: string, iv: string): string

This decrypts the data string encrypted using the AES-CBC algorithm. The specifications are the same as in the encryptAES method.

crypto.generateRSAKeys(keySize: number): table

This generates a RSA keypair of size keySize.

crypto.encryptRSA(data: string, publicKey: string): string

This encrypts the data string using the RSA algorithm. The publicKey must be generated using the generateRSAKeys method.

crypto.decryptRSA(data: string, privateKey: string): string

This decrypts the data string encrypted using the RSA algorithm. The privateKey must be from the same keypair as the publicKey used to encrypt the data.

crypto.hashMD5(data: string): string

This computes the MD5 hash of the data string.

crypto.hashSHA512(data: string): string

This computes the SHA-512 hash of the data string

crypto.hmacMD5(data: string, key: string): string

This computes the HmacMD5 hash of the data string.

crypto.hmacSHA512(data: string, key: string): string

This computes the HmacSHA-512 hash of the data string