lune-org/lune

process.spawn: writing to stdin

Closed this issue · 3 comments

Adding a key to the options table of process.spawn to write to stdin could help with some use cases, such as performant hashing:

local password = 'password'
local hash = process.spawn('openssl', { 'dgst', '-sha256', '-' }, { stdin: password }).stdout

This is quite useful, I'm open to implement this soon.

I've implemented and PR'ed this (see above). Example usage:

local process = require("@lune/Process")

local password = 'password'
local hash = process.spawn('openssl', { 'dgst', '-sha256', '-' }, { stdin = password }).stdout

print("Got hash: ", hash)

...which should print:

Got hash:  SHA2-256(stdin)= e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

That looks like exactly what I need, thank you!