Thread: Module: Crypto
View Single Post
sonshitsu
New Member
Join Date: Aug 2022
Old 08-25-2022 , 08:48   Re: Module: Crypto
Reply With Quote #7

Quote:
Originally Posted by iNvectus View Post
Description
This module is used for cryptographic purposes. It is made to be simple of usage. You need hash - you get it.

Algorithms
Code:
  • MD5
  • SHA1
  • SHA256
  • SHA3
  • CRC32
Natives
It uses only one native - crypto_hash and has three arguments.

First argument is the algorithm type.
Second argument is the string you want to hash
Third argument is the variable to save the result from the hash.

Code:
native crypto_hash(const iHashType[], const iText[], const iResult[]);

The function has return codes, which of them are:
Code:
  • 0 - Everything is okay, the hash has been done successfully
  • 1 - The hash could not be done, the algorithm is unsupported
  • -1 - Unknown error, should report in this thread or create an issue in Github
Let's see an example usage:
Code:
#include <amxmodx> #include <crypto> public plugin_init() {     register_clcmd("say /crypto", "cmdCrypto"); } public cmdCrypto(id) {     new iHash[256];     new iSuccess = crypto_hash("sha3", "Test", iHash);         if(iSuccess == 0)         client_print(id, print_chat, "Success: %s", iHash);     else         client_print(id, print_chat, "No Success: %d", iSuccess); }

Installation
  1. Install Visual Studio
  2. Download the source code
  3. Open crypto.sln file
  4. Once the solution is opened, go to Build -> Build Solution
  5. Once the compilation is complete, you can go to the project folder and copy the crypto_amxx.dll from Release folder
  6. Place it into amxmodx/modules folder and copy crypto.inc into amxmodx/scripting/include

Changelog
Code:
  • v1.0 - Initial release
Future
I am willing to implement as much algorithms as possible - both encryption/decryption and hashing.

Code:
    • HMAC
    • Caesar Cipher
    • KECCAK
    • Base64 (probably)
Download
You can find the source code available here:
https://github.com/stfkolev/crypto-amxx
Thank you.
sonshitsu is offline