import { Secret, SignOptions, VerifyOptions, JwtPayload, DecodeOptions } from 'jsonwebtoken';

/**
 * Hash utilities for common cryptographic hashing algorithms
 */
declare namespace hash {
    /**
     * Generates an MD5 hash of the input string
     *
     * @param data - The string to hash
     * @returns The MD5 hash as a hexadecimal string
     *
     * @example
     * ```typescript
     * hash.md5('hello world')
     * // Returns: '5eb63bbbe01eeed093cb22bb8f5acdc3'
     * ```
     */
    function md5(data: string): string;
    /**
     * Generates a SHA-1 hash of the input string
     *
     * @param data - The string to hash
     * @returns The SHA-1 hash as a hexadecimal string
     *
     * @example
     * ```typescript
     * hash.sha1('hello world')
     * // Returns: '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
     * ```
     */
    function sha1(data: string): string;
    /**
     * Generates a SHA-256 hash of the input string
     *
     * @param data - The string to hash
     * @returns The SHA-256 hash as a hexadecimal string
     *
     * @example
     * ```typescript
     * hash.sha256('hello world')
     * // Returns: 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9'
     * ```
     */
    function sha256(data: string): string;
    /**
     * Generates a SHA-512 hash of the input string
     *
     * @param data - The string to hash
     * @returns The SHA-512 hash as a hexadecimal string
     *
     * @example
     * ```typescript
     * hash.sha512('hello world')
     * // Returns: '309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f'
     * ```
     */
    function sha512(data: string): string;
    /**
     * Generates a SHA3-256 hash of the input string
     *
     * @param data - The string to hash
     * @returns The SHA3-256 hash as a hexadecimal string
     *
     * @example
     * ```typescript
     * hash.sha3_256('hello world')
     * // Returns: '644bcc7e564373040999aac89e7622f3ca71fba1d972fd94a31c3bfbf24e3938'
     * ```
     */
    function sha3_256(data: string): string;
    /**
     * Generates a SHA3-512 hash of the input string
     *
     * @param data - The string to hash
     * @returns The SHA3-512 hash as a hexadecimal string
     *
     * @example
     * ```typescript
     * hash.sha3_512('hello world')
     * // Returns: '840006653e9ac9e95117a15c915caab81662918e925de9e004f774ff82d7079a40d4d27b1b372657c61d46d470304c88c788b3a4527ad074d1dccbee5dbaa99a'
     * ```
     */
    function sha3_512(data: string): string;
}
/**
 * Password hashing and comparison utilities using bcrypt
 */
declare namespace password {
    /**
     * Checks if a string is a valid bcrypt hash
     *
     * @param str - The string to check
     * @returns True if the string is a valid bcrypt hash, false otherwise
     *
     * @example
     * ```typescript
     * password.isBcryptHash('$2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy')
     * // Returns: true
     *
     * password.isBcryptHash('not a hash')
     * // Returns: false
     * ```
     */
    function isBcryptHash(str: string): boolean;
    /**
     * Encrypts a password using bcrypt
     *
     * @param password - The plain text password to encrypt
     * @param rounds - The number of rounds to use for salt generation (default: 10)
     * @returns A promise that resolves to the encrypted password hash
     *
     * @example
     * ```typescript
     * await password.encryptPassword('mySecurePassword')
     * // Returns: '$2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy'
     * ```
     */
    function encryptPassword(password: string, rounds?: number): Promise<string>;
    /**
     * Compares a plain text password with a bcrypt hash
     *
     * @param password - The plain text password to compare
     * @param hash - The bcrypt hash to compare against
     * @returns A promise that resolves to true if the password matches the hash, false otherwise
     *
     * @example
     * ```typescript
     * await password.comparePassword('myPassword', '$2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy')
     * // Returns: true or false
     * ```
     */
    function comparePassword(password: string, hash: string): Promise<boolean>;
}
/**
 * Cryptographic key generation utilities
 */
declare namespace keys {
    /**
     * Generates an RSA key pair
     *
     * @param modulusLength - The modulus length in bits (default: 2048)
     * @returns An object containing the public and private keys in PEM format
     *
     * @example
     * ```typescript
     * const { publicKey, privateKey } = keys.rsa()
     * // Returns: { publicKey: '-----BEGIN PUBLIC KEY-----...', privateKey: '-----BEGIN PRIVATE KEY-----...' }
     * ```
     */
    function rsa(modulusLength?: number): {
        publicKey: string;
        privateKey: string;
    };
    /**
     * Generates an Ed25519 key pair
     *
     * @returns A promise that resolves to an object containing the public and private keys as hex strings
     *
     * @example
     * ```typescript
     * const { publicKey, privateKey } = await keys.ed25519()
     * // Returns: { publicKey: '1a2b3c...', privateKey: '9f8e7d...' }
     * ```
     */
    function ed25519(): Promise<{
        publicKey: string;
        privateKey: string;
    }>;
}
/**
 * JSON Web Token (JWT) utilities
 */
declare namespace jwt {
    /**
     * Signs a JWT with the provided payload and secret
     *
     * @param payload - The payload to encode in the JWT
     * @param secret - The secret key to sign the JWT with
     * @param options - Optional JWT sign options (algorithm, expiresIn, etc.)
     * @returns The signed JWT token
     *
     * @example
     * ```typescript
     * const token = Enc.jwt.sign({ userId: 123 }, 'mySecret', { expiresIn: '1h' })
     * // Returns: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
     * ```
     */
    function sign(payload: string | object | Buffer, secret: Secret, options?: SignOptions): string;
    /**
     * Verifies a JWT token
     *
     * @param token - The JWT token to verify
     * @param secret - The secret key to verify the JWT with
     * @param options - Optional JWT verify options
     * @returns The decoded payload if verification succeeds
     * @throws Will throw an error if verification fails
     *
     * @example
     * ```typescript
     * try {
     *   const payload = Enc.jwt.verify(token, 'mySecret')
     *   console.log(payload) // { userId: 123, iat: 1234567890, exp: 1234571490 }
     * } catch (err) {
     *   console.error('Invalid token')
     * }
     * ```
     */
    function verify(token: string, secret: Secret, options?: VerifyOptions): string | JwtPayload;
    /**
     * Decodes a JWT token without verifying its signature
     *
     * @param token - The JWT token to decode
     * @param options - Optional decode options
     * @returns The decoded payload or null if the token is invalid
     *
     * @example
     * ```typescript
     * const payload = Enc.jwt.decode(token)
     * // Returns: { userId: 123, iat: 1234567890, exp: 1234571490 }
     * ```
     */
    function decode(token: string, options?: DecodeOptions): null | string | JwtPayload;
}
/**
 * Digital signature utilities
 */
declare namespace sign {
    /**
     * Signs data using Ed25519 private key
     *
     * @param privateKey - The Ed25519 private key as a hex string
     * @param data - The data to sign
     * @returns A promise that resolves to the signature as a hex string
     *
     * @example
     * ```typescript
     * const { privateKey } = await keys.ed25519()
     * const signature = await sign.ed25519(privateKey, 'message to sign')
     * // Returns: 'a1b2c3d4...'
     * ```
     */
    function ed25519(privateKey: string, data: string): Promise<string>;
    /**
     * Verifies an Ed25519 signature
     *
     * @param publicKey - The Ed25519 public key as a hex string
     * @param signature - The signature to verify as a hex string
     * @param data - The original data that was signed
     * @returns A promise that resolves to true if the signature is valid, false otherwise
     *
     * @example
     * ```typescript
     * const isValid = await sign.verifyEd25519(publicKey, signature, 'message to sign')
     * // Returns: true or false
     * ```
     */
    function verifyEd25519(publicKey: string, signature: string, data: string): Promise<boolean>;
}

declare const enc_hash: typeof hash;
declare const enc_jwt: typeof jwt;
declare const enc_keys: typeof keys;
declare const enc_password: typeof password;
declare const enc_sign: typeof sign;
declare namespace enc {
  export { enc_hash as hash, enc_jwt as jwt, enc_keys as keys, enc_password as password, enc_sign as sign };
}

export { enc as e, hash as h, jwt as j, keys as k, password as p, sign as s };
