Skip to content

πŸ›‘οΈ SecureVault Login Manager β€” a reusable Kotlin console tool that demonstrates the five scoped functions clearly while staying practical and open for extension (logging, security modules, user management, etc.).

License

Notifications You must be signed in to change notification settings

cosmichackerx/SecureVault-Login-Manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SecureVault-Login-Manager

πŸ›‘οΈ SecureVault Login Manager β€” a reusable Kotlin console tool that demonstrates the five scoped functions clearly while staying practical and open for extension (logging, security modules, user management, etc.).

/*
 * =============================================================
 *  SecureVault Login Manager
 *  -------------------------------------
 *  Author   : Muhammad Arslan (cosmichackerx)
 *  Language : Kotlin
 *  Purpose  : Demonstrate Kotlin Scoped Functions (let, run, apply, with, also)
 *  License  : MIT License
 * =============================================================
 */

import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

// =======================
// Data Model
// =======================
data class User(
    var username: String = "",
    var email: String = "",
    var password: String = ""
) {
    fun securityScan(): String {
        // Simulate security checks
        val firewall = true
        val malware = true
        val dataIntegrity = true

        return if (firewall && malware && dataIntegrity) {
            "βœ… All systems secure"
        } else if (!firewall && !malware && !dataIntegrity) {
            "⚠️ Warning: Suspicious activity detected"
        } else {
            "🚨 Critical error: System not fully secure"
        }
    }

    fun showDashboard() {
        println("\nπŸ“Š ==== User Dashboard ====")
        println("Username : $username")
        println("Email    : $email")
        println("Status   : Logged in successfully βœ…")
        println("============================")
    }
}

// =======================
// Main Application
// =======================
fun main() {
    println("πŸ›‘οΈ Welcome to SecureVault Login Manager")
    println("=======================================")

    // ISO 8601 formatted time stamp
    val currentTime = LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)

    // STEP 1: apply β†’ Initialize user
    val user = User().apply {
        username = "Muhammad"
        email = "cosmichackerx@gmail.com"
        password = "1234567"
        println("\n[apply] Initializing user profile...")
    }

    // STEP 2: also β†’ Log activity / audit
    user.also {
        println("[also] ${it.username} attempted login at $currentTime using email: ${it.email}")
    }

    // STEP 3: run β†’ Perform security checks & get result
    val scanResult = user.run {
        println("\n[run] Performing security scan for user '$username'...")
        securityScan()
    }
    println("[run] Result: $scanResult")

    // STEP 4: let β†’ Validate data safely
    val verifiedUser = user.let {
        println("\n[let] Validating user data...")
        if (it.email.isNotEmpty() && it.password.isNotEmpty()) {
            println("βœ… Credentials verified for ${it.username}")
            it
        } else {
            println("❌ Invalid credentials! Access denied.")
            null
        }
    }

    // STEP 5: with β†’ Display dashboard if login succeeded
    if (verifiedUser != null) {
        with(verifiedUser) {
            println("\n[with] Loading user dashboard...")
            showDashboard()
            println("✨ Welcome back, $username! Stay safe and secure.")
        }
    } else {
        println("\nUser validation failed. Exiting SecureVault.")
    }

    println("\n🧠 Program executed successfully.")
}

# πŸ›‘οΈ SecureVault Login Manager

A practical **Kotlin console application** demonstrating all **five scoped functions** β€” `let`, `run`, `apply`, `with`, and `also` β€” through a real-world scenario of a secure login and system verification process.  

---

## πŸš€ Overview

`SecureVault Login Manager` simulates a login environment where:
1. A **user** object is created and configured.
2. Actions are **logged** for auditing.
3. The system performs a **security scan**.
4. User data is **validated** safely.
5. A **dashboard** is displayed for successful logins.

It’s a simple yet powerful way to understand **Kotlin scoped functions in action**, built for learners, developers, and educators alike.

---

## 🧠 Concepts Covered

| Function | Purpose | Behavior | Returns |
|-----------|----------|-----------|----------|
| `apply` | Initialize / setup object | Access with `this` | The object itself |
| `also` | Log side effects | Access with `it` | The object itself |
| `run` | Execute block and return result | Access with `this` | Lambda result |
| `let` | Transform or validate safely | Access with `it` | Lambda result |
| `with` | Operate on non-null object | Access with `this` | Lambda result |

---

## πŸ’Ό Real-World Analogy

| Function | Real-Life Role | Example |
|-----------|----------------|----------|
| `apply` | Filling your ID form | Configure user details |
| `also` | CCTV log entry | Log login attempt |
| `run` | Security scan | Check system safety |
| `let` | Guard validation | Verify credentials |
| `with` | Vault access | Open user dashboard |

---

## πŸ“‚ Project Structure


SecureVault-Login-Manager/
β”‚
β”œβ”€β”€ SecureVault.kt      ← Main Kotlin source file
β”œβ”€β”€ LICENSE             ← MIT License file
└── README.md           ← Project documentation (this file)

πŸ› οΈ How to Run

1. Clone the repository

git clone https://github.com/cosmichackerx/SecureVault-Login-Manager.git
cd SecureVault-Login-Manager

2. Compile the Kotlin file

kotlinc SecureVault.kt -include-runtime -d SecureVault.jar

3. Run the program

java -jar SecureVault.jar

🧩 Sample Output

πŸ›‘οΈ Welcome to SecureVault Login Manager
=======================================

[apply] Initializing user profile...
[also] Muhammad attempted login at 2025-10-23T10:15:30 using email: cosmichackerx@gmail.com

[run] Performing security scan for user 'Muhammad'...
βœ… All systems secure

[let] Validating user data...
βœ… Credentials verified for Muhammad

[with] Loading user dashboard...

πŸ“Š ==== User Dashboard ====
Username : Muhammad
Email    : cosmichackerx@gmail.com
Status   : Logged in successfully βœ…
============================
✨ Welcome back, Muhammad! Stay safe and secure.

🧠 Program executed successfully.

🌍 Educational Purpose

This project is designed to help Kotlin learners understand:

  • Null safety and scope isolation
  • Object initialization and chaining
  • Readable code structure using scoped functions
  • Realistic security-themed programming patterns

🧩 Author

πŸ‘€ Muhammad Arslan πŸ“§ Email: cosmichackerx@gmail.com πŸ’» GitHub: @cosmichackerx 🌐 Project Type: Educational / Open Source


πŸ“œ License

This project is licensed under the MIT License β€” you’re free to use, modify, and share it for learning or development purposes. See the LICENSE file for details.

Copyright (c) 2025 Muhammad Arslan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction...

🧭 Keywords

Kotlin Scoped Functions apply also run let with Kotlin Tutorial Cybersecurity Educational Project Console App OOP


🌟 Contribute

Want to make SecureVault even cooler?

  • Fork the repo
  • Add new features (e.g., password encryption, login attempts counter)
  • Submit a pull request ✨

About

πŸ›‘οΈ SecureVault Login Manager β€” a reusable Kotlin console tool that demonstrates the five scoped functions clearly while staying practical and open for extension (logging, security modules, user management, etc.).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages