Welcome . In this doc you gonna learn how to use SpiderCrypt SDK for data security. It provides robust functionalities for encryption, decryption, hashing, signing, and verifying data, using shared authentication keys and user identifiers to ensure traceability and security.
Classes and Methods
Class SpiderCrypt
This class is the core of the SpiderCrypt SDK and enables all the main cryptographic operations.
Initialization
SpiderCrypt(secret_key: str)
Parameter:
secret_key: Shared secret key used to initialize the class. It is required for all secure operations.
Description: Verifies if the signature of the data is valid.
Parameters:
data: Original data (string).
signature: Signature to verify (as bytes).
auth_key: Authentication key used for this operation.
user_id: Identifier of the user performing the operation.
Returns: A boolean indicating if the signature is valid (True) or not (False).
Error Handling
PermissionError
Raised when authentication fails (e.g., if auth_key is incorrect).
Exception
Raised for any other non-specific errors (e.g., corrupted data or invalid format).
Example Usage
Here is a complete example of using the main features of the API:
from spidercrypt import SpiderCrypt # Import the SpiderCrypt librarydefmain():# Shared authentication key for security auth_key ="d7kTW+Hz67I9B8F8NenqqbgDSd11HSFyT3D5Zt5GkK0="# Secure secret key# Initialize SpiderCrypt with the secret key for secure operations cipher =SpiderCrypt(secret_key=auth_key)# Example data to secure data ="Sensitive data to secure."# Your data to protect user_id ="user001"# User identifier for tracking actionstry:# Encrypt the data encrypted_data = cipher.encrypt(data, auth_key, user_id)print(f"Encrypted data: {encrypted_data.decode()}")# Decrypt the data decrypted_data = cipher.decrypt(encrypted_data, auth_key, user_id)print(f"Decrypted data: {decrypted_data}")# Hash the data (to ensure integrity) hashed_data = cipher.hash_data(data, auth_key, user_id)print(f"Hashed data: {hashed_data.hex()}")# Sign the data to ensure authenticity signature = cipher.sign_data(data, auth_key, user_id)print(f"Data signature: {signature.hex()}")# Verify the signature to ensure integrity is_valid = cipher.verify_signature(data, signature, auth_key, user_id)print(f"Signature valid: {is_valid}")exceptPermissionErroras e:print(f"Authentication error: {e}")exceptExceptionas e:print(f"An error occurred: {e}")if__name__=="__main__":main()
Additional Notes
Ensure the auth_key remains strictly confidential.
Trace operations by user (user_id) for better security management and audits.
Test all operations before deploying them in a production environment.
Here some SDK :
Python
pipinstallspidercrypt
Java
Make sure to have the SpiderCrypt library as a .jar file and add it to your project.
Ruby
geminstallspidercrypt
Go
Use the Go package manager to import spidercrypt.
gogetgithub.com/spidercrypt/spidercrypt
C#
Add the SpiderCrypt reference via NuGet or the .dll file.