380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
|
{
uint8_t buf[64];
size_t i;
assert(RAND_pseudo_bytes(buf, 64) >= 0);
for (i = 0; i < 64; i++) {
uint8_t tmp = (buf[i] % ('~' - '!')) + '!';
while (tmp == ',')
tmp = ((buf[i] >> 1) % ('~' - '!')) + '!';
buf[i] = tmp;
}
return [OFString stringWithCString: (char*)buf
encoding: OF_STRING_ENCODING_ASCII
length: 64];
}
|
>
|
>
|
<
<
|
|
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
|
{
uint8_t buf[64];
size_t i;
assert(RAND_pseudo_bytes(buf, 64) >= 0);
for (i = 0; i < 64; i++) {
// Restrict salt to printable range, but do not include '~'...
buf[i] = (buf[i] % ('~' - '!')) + '!';
// ...so we can use it to replace ','
if (buf[i] == ',')
buf[i] = '~';
}
return [OFString stringWithCString: (char*)buf
encoding: OF_STRING_ENCODING_ASCII
length: 64];
}
|