Skip to content

Instantly share code, notes, and snippets.

@Strajk
Created January 5, 2025 16:30
Show Gist options
  • Save Strajk/2e7d57e65e69365e02567d103f812496 to your computer and use it in GitHub Desktop.
Save Strajk/2e7d57e65e69365e02567d103f812496 to your computer and use it in GitHub Desktop.
BananaCrypt Documentation
### **BananaCrypt Documentation**
* * *
## **Overview**
BananaCrypt is a revolutionary encryption library inspired by the peeling complexity of bananas. It uses the potassium levels of bananas as the base for its cryptographic algorithms. Perfect for developers who want to keep their secrets safe and fruity.
* * *
## **Installation**
bash
Copy code
`pnpm add banana-crypt`
* * *
## **Constructor**
### `BananaCrypt(apiKey: string, options?: BananaCryptOptions)`
#### **Parameters**:
- `apiKey` (_string_, **required**)
Your API key to authenticate with BananaCrypt's remote potassium-analysis server.
- `options` (_object_, **optional**)
Additional configuration options:
- `debug` (_boolean_, default: `false`) - Enables debug logging.
- `region` (_string_, default: `"us-east-1"`) - Specify the region for the potassium server.
#### **Example**:
typescript
Copy code
`import BananaCrypt from 'banana-crypt'; const crypt = new BananaCrypt('your-api-key', { debug: true });`
* * *
## **Methods**
### 1\. **`encrypt(message: string): string`**
Encrypts a given message using BananaCrypt's proprietary algorithm.
#### **Parameters**:
- `message` (_string_, **required**) - The plaintext message to encrypt.
#### **Returns**:
- An encrypted string.
#### **Example**:
typescript
Copy code
`const encrypted = crypt.encrypt('Hello, World!'); console.log(encrypted); // Output: Encrypted gibberish`
* * *
### 2\. **`decrypt(encryptedMessage: string): string`**
Decrypts a BananaCrypt-encrypted message.
#### **Parameters**:
- `encryptedMessage` (_string_, **required**) - The encrypted message to decrypt.
#### **Returns**:
- The original plaintext message.
#### **Example**:
typescript
Copy code
`const decrypted = crypt.decrypt(encrypted); console.log(decrypted); // Output: Hello, World!`
* * *
### 3\. **`analyzeBanana(banana: string): number`**
Analyzes a banana's potassium level from an image URL or file path.
#### **Parameters**:
- `banana` (_string_, **required**) - The URL or file path to the banana image.
#### **Returns**:
- A potassium level as a number.
#### **Example**:
typescript
Copy code
``const potassium = crypt.analyzeBanana('path/to/banana.jpg'); console.log(`Potassium level: ${potassium}`);``
* * *
### 4\. **`generateKey(potassiumLevel: number): string`**
Generates an encryption key based on a given potassium level.
#### **Parameters**:
- `potassiumLevel` (_number_, **required**) - The potassium level to generate the key.
#### **Returns**:
- A cryptographic key as a string.
#### **Example**:
typescript
Copy code
``const key = crypt.generateKey(420); console.log(`Generated Key: ${key}`);``
* * *
### 5\. **`isValidKey(key: string): boolean`**
Validates whether a given key is valid for use in BananaCrypt.
#### **Parameters**:
- `key` (_string_, **required**) - The cryptographic key to validate.
#### **Returns**:
- `true` if the key is valid, `false` otherwise.
#### **Example**:
typescript
Copy code
`const isValid = crypt.isValidKey('some-random-key'); console.log(isValid); // Output: true or false`
* * *
## **Example Usage**
A "Hello, World!" program using BananaCrypt:
typescript
Copy code
`import BananaCrypt from 'banana-crypt'; // Initialize BananaCrypt const crypt = new BananaCrypt('your-api-key', { debug: true }); // Encrypt a message const encrypted = crypt.encrypt('Hello, World!'); console.log('Encrypted:', encrypted); // Decrypt the message const decrypted = crypt.decrypt(encrypted); console.log('Decrypted:', decrypted);`
* * *
## **License**
MIT License – because bananas should be free for everyone. 🍌
4o
##### You said:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment