luajitos

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

SETUP_PASSWORD.md (1852B)


      1 # Setup Administrator Password
      2 
      3 To use the password prompt system, you need to generate a password hash.
      4 
      5 ## Quick Setup
      6 
      7 1. Boot into LuajitOS
      8 2. Open the shell or create a simple test app
      9 3. Run this code to generate a hash for password "admin":
     10 
     11 ```lua
     12 local password = "admin"
     13 local salt = "LuajitOS-AdminSalt-v1"
     14 local hash = crypto.Argon2id(password, salt)
     15 
     16 -- Base64 encode function
     17 local b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
     18 local function base64_encode(data)
     19     if not data or #data == 0 then return "" end
     20     local result = {}
     21     for i = 1, #data, 3 do
     22         local b1 = string.byte(data, i)
     23         local b2 = string.byte(data, i + 1) or 0
     24         local b3 = string.byte(data, i + 2) or 0
     25         local n = b1 * 65536 + b2 * 256 + b3
     26         local c1 = bit.band(bit.rshift(n, 18), 63) + 1
     27         local c2 = bit.band(bit.rshift(n, 12), 63) + 1
     28         local c3 = bit.band(bit.rshift(n, 6), 63) + 1
     29         local c4 = bit.band(n, 63) + 1
     30         table.insert(result, b64chars:sub(c1, c1))
     31         table.insert(result, b64chars:sub(c2, c2))
     32         if i + 1 <= #data then table.insert(result, b64chars:sub(c3, c3)) else table.insert(result, '=') end
     33         if i + 2 <= #data then table.insert(result, b64chars:sub(c4, c4)) else table.insert(result, '=') end
     34     end
     35     return table.concat(result)
     36 end
     37 
     38 print("Password hash (base64):")
     39 print(base64_encode(hash))
     40 ```
     41 
     42 4. Copy the output hash
     43 5. Save it to `/os/password.hash` (you'll need filesystem permission)
     44 6. Rebuild the ISO or modify the file in the ramdisk
     45 
     46 ## Alternative: Use Crypto CLI
     47 
     48 If you have the crypto CLI app with appropriate permissions:
     49 
     50 ```bash
     51 crypto Argon2id "admin" -salt "LuajitOS-AdminSalt-v1" -b64
     52 ```
     53 
     54 Then save the output to `/os/password.hash`.
     55 
     56 ## Security Note
     57 
     58 Change "admin" to a strong password in production!