11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
* → mkpw is unlikely to be portable to non-POSIX
* systems, but should run fine on Linux as well
* as BSDs with getrandom() support.
*/
#include <unistd.h>
#include <sys/random.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#define sz(a) ( sizeof (a) / sizeof (a) [0] )
#define say(x) (write(2, (x), sizeof (x)))
#ifdef _CLIPBOARD
................................................................................
char buf[len+1];
/* *buf = 0; */
unsigned char noise[len];
for (size_t i = 0; i<q; ++i) {
unsigned char* cur = noise;
getrandom(noise, len, 0);
for(char* ptr = buf; ptr < buf + len; ++ptr, ++cur) {
*ptr = tbl[*cur % chars]; /* such a waste of entropy… :( */
}
buf[len] = '\n';
write(1, buf, len + 1);
|
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
* → mkpw is unlikely to be portable to non-POSIX
* systems, but should run fine on Linux as well
* as BSDs with getrandom() support.
*/
#include <unistd.h>
#include <sys/random.h>
#include <sys/syscall.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#define sz(a) ( sizeof (a) / sizeof (a) [0] )
#define say(x) (write(2, (x), sizeof (x)))
#ifdef _CLIPBOARD
................................................................................
char buf[len+1];
/* *buf = 0; */
unsigned char noise[len];
for (size_t i = 0; i<q; ++i) {
unsigned char* cur = noise;
syscall(SYS_getrandom, noise, len, 0);
/* getrandom(noise, len, 0); // android doesnt like it */
for(char* ptr = buf; ptr < buf + len; ++ptr, ++cur) {
*ptr = tbl[*cur % chars]; /* such a waste of entropy… :( */
}
buf[len] = '\n';
write(1, buf, len + 1);
|