<?php

use Illuminate\Support\Facades\Route;
use Ramsey\Uuid\Uuid;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

// Erzeuge ein gehashtes Passwort
Route::get('pw/{value?}', function($value = null) {
    if(!empty($value)) {
        return [
            'password' => $value,
            'hashed'   => Hash::make($value)
        ];
    }

    $randomPassword = Str::random();
    return [
        'password' => $randomPassword,
        'hashed'   => Hash::make($randomPassword)
    ];
});

// Verschlüssele einen Wert
Route::get('enc/{value}', function($value) {
    return [
        'uncrypted' => $value,
        'encrypted' => encrypt($value)
    ];
});

// Entschlüssele einen Wert
Route::get('dec/{value}', function($value) {
    return [
        'encrypted' => $value,
        'decrypted' => decrypt($value)
    ];
});

// Zufallszeichen mit Länge
Route::get('random/{length?}', function(int $length = 16) {
    return [
        'string' => Str::random($length),
        'length' => $length
    ];
})->name('random-string');

// Erzeuge UUID
Route::get('uuid', function() {
    return [
        Uuid::uuid4()
    ];
});

// Erzeuge UUID
Route::get('slug/{value?}', function($value) {
    return [
        'value' => $value,
        'slug'  => Str::slug($value)
    ];
})->name('slug');

// phpInfo
Route::get('info', function() { return phpinfo(); });
