// SPDX-License-Identifier: Apache-2.0
// Copyright 2025 Simple Encryption Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef SIMPLE_ENCRYPTION_H
#define SIMPLE_ENCRYPTION_H

#include <string>

/**
 * SimpleEncryption class implements a basic Caesar cipher encryption algorithm.
 * This class provides methods to encrypt and decrypt text using a shift-based
 * substitution cipher where each letter is shifted by a fixed number of positions
 * in the alphabet.
 */
class SimpleEncryption {
public:
    // Lifecycle
    /**
     * Constructor - Initialize encryption with specified shift value
     * @param shift Number of positions to shift each character (default: 3)
     */
    explicit SimpleEncryption(int shift = 3);
    
    /**
     * Destructor - Clean up resources
     */
    ~SimpleEncryption();

    // Operations
    /**
     * Encrypt a single character using Caesar cipher
     * @param input_char Character to encrypt
     * @return Encrypted character
     */
    char EncryptChar(char input_char) const;
    
    /**
     * Decrypt a single character using Caesar cipher
     * @param input_char Character to decrypt
     * @return Decrypted character
     */
    char DecryptChar(char input_char) const;
    
    /**
     * Encrypt an entire string
     * @param plaintext String to encrypt
     * @return Encrypted string
     */
    std::string EncryptString(const std::string& plaintext) const;
    
    /**
     * Decrypt an entire string
     * @param ciphertext String to decrypt
     * @return Decrypted string
     */
    std::string DecryptString(const std::string& ciphertext) const;

    // Accessors
    /**
     * Set new shift value for encryption/decryption
     * @param shift New shift value
     */
    void SetShiftValue(int shift);
    
    /**
     * Get current shift value
     * @return Current shift value
     */
    int GetShiftValue() const;

    // Utilities
    /**
     * Demonstrate encryption functionality with sample text
     */
    void DemoEncryption() const;

private:
    // Constants
    static const int ALPHABET_SIZE = 26;

    // Attributes
    int mShiftValue;  ///< Number of positions to shift characters

    // Helper methods
    /**
     * Check if character is alphabetic
     * @param c Character to check
     * @return true if alphabetic, false otherwise
     */
    bool IsAlpha(char c) const;
    
    /**
     * Check if character is uppercase
     * @param c Character to check
     * @return true if uppercase, false otherwise
     */
    bool IsUpper(char c) const;
};

#endif // SIMPLE_ENCRYPTION_H