srandom | FASTEST /dev/urandom PRNG | Runtime Evironment library

 by   josenk C Version: 1.37 License: GPL-3.0

kandi X-RAY | srandom Summary

kandi X-RAY | srandom Summary

srandom is a C library typically used in Server, Runtime Evironment, Nodejs applications. srandom has no bugs, it has no vulnerabilities, it has a Strong Copyleft License and it has low support. You can download it from GitHub.

srandom is a Linux kernel module that can be used to replace the built-in /dev/urandom & /dev/random device files. It is secure and VERY fast. My tests show it over 150x faster then /dev/urandom. It should compile and install on any Linux 3.10+ kernel. It passes all the randomness tests using the dieharder tests. srandom was created as an improvement to the built-in random number generators. I wanted a much faster random number generator to wipe ssd disks. Through many hours of testing and trial-and-error, I came up with an algorithm that is many times faster than urandom, but still produces excellent random numbers. You can wipe multiple SSDs at the same time. The built-in generators (/dev/random and /dev/urandom) are technically not flawed. /dev/random (the true random number generator) is BLOCKED most of the time waiting for more entropy. If you are running your Linux in a VM, /dev/random is basically unusable. /dev/urandom is unblocked, but still very slow.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              srandom has a low active ecosystem.
              It has 39 star(s) with 11 fork(s). There are 7 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 2 open issues and 10 have been closed. On average issues are closed in 411 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of srandom is 1.37

            kandi-Quality Quality

              srandom has 0 bugs and 0 code smells.

            kandi-Security Security

              srandom has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              srandom code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              srandom is licensed under the GPL-3.0 License. This license is Strong Copyleft.
              Strong Copyleft licenses enforce sharing, and you can use them when creating open source projects.

            kandi-Reuse Reuse

              srandom releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of srandom
            Get all kandi verified functions for this library.

            srandom Key Features

            No Key Features are available at this moment for srandom.

            srandom Examples and Code Snippets

            No Code Snippets are available at this moment for srandom.

            Community Discussions

            QUESTION

            How can I generate specified number of integers in Linux?
            Asked 2021-Oct-11 at 12:50

            I found a lot of questions/answers related to this issue but I failed to choose what exactly what I need.

            How can I generate specified number of integers?

            ...

            ANSWER

            Answered 2021-Oct-11 at 12:24

            I would use hexdump and /dev/urandom if they are available:

            Source https://stackoverflow.com/questions/69525565

            QUESTION

            Why does adding an if(!memcmp()) speed up a loop that makes random short strides through a huge byte array?
            Asked 2021-Sep-17 at 07:32

            Sorry, I have never understood the rules here. I have deleted all the duplicate posts I have posted. This is the first related issue. Please do not mark this post as a duplicate of my other one(Reduce the number of executions by 3 times, but the execution efficiency is almost unchanged. In C), even if the code is somewhat similar, they raise very different questions.These are also two problems that I found on the same day. A similar post has been repeated by "misjudgment" and then closed. It may be that I did not clarify this issue. I really hope to get the answer, so I reposted it. I hope everyone can see the problem clearly, thank you very much!

            In the following C code, I added an "if" statement to the loop of the first test time, and the execution times are exactly the same. In theory, it should be slower. Even though branch prediction can make their performance almost the same, it actually becomes a lot faster. What is the principle of this? I tried to use clang and gcc compilers to run in Mac and Linux environments respectively, and tried various optimization levels. In order to prevent the cache from being affected, I let the faster ones execute first, but the loops with redundant code execute faster.

            If you think my description is not credible, please compile the following code into your computer and run it. Hope someone can answer this question for me,thanks.

            C code:

            ...

            ANSWER

            Answered 2021-Sep-17 at 07:32

            The key bottleneck is the load-use latency of cache misses while striding through tex[], as part of the dependency chain from old i to new i. Lookups from the small rand_array[] will hit in cache and just add about 5 cycles of L1d load-use latency to the loop-carried dependency chain, making it even more unlikely for anything other than latency through i to be relevant to the overall speed of the loop. (Jérôme Richard's answer on your previous question discusses that latency dep chain and the random stride increment.)

            memcmp(tex+i, str, SLen) might be acting as prefetching if tex+i is near the end of a cache line. If you compiled with -O0, you're calling glibc memcmp so the SSE 16-byte or AVX2 32-byte load done in glibc memcmp crosses a cache-line boundary and pulls in the next line. (IIRC, glibc memcmp checks and avoids page crossing, but not cache-line splits, because those are relatively cheap on modern CPUs. Single-step into it to see. Into the 2nd call to avoid lazy dynamic linking, or compile with -fno-plt).

            Possibly touching some cache lines that would have been skipped by the random stride helps HW prefetch be more aggressive and detect it as a sequential access pattern. A 32-byte AVX load is half a cache line, so it's fairly likely to cross into the next one.

            So a more-predictable sequence of cache-line requests seen by the L2 cache is a plausible explanation for the memcmp version being faster. (Intel CPUs put the main prefetchers in the L2.)

            If you compile with optimization, that 10-byte memcmp inlines and in the inner loop only touches 8 bytes. (If they match, then it jumps to another block where it checks the last 2. But it's exceedingly unlikely that ever happens).

            This might be why -O0 is faster than -O3 on my system, with GCC11.1 on i7-6700k Skylake with DDR4-2666 DRAM, on Arch GNU/Linux. (Your question didn't bother to specify which compiler and options your numbers were from, or which hardware.)

            Source https://stackoverflow.com/questions/69213272

            QUESTION

            Reduce the number of executions by 3 times, but the execution efficiency is almost unchanged. In C
            Asked 2021-Sep-16 at 21:16

            In C, I reduced the total number of loop executions by nearly 3 times, but through testing the execution time, I found that there is almost no improvement in doing so. All optimization levels have been tested, and the results are basically the same(including O0, O1, O2 and O3). I guess it’s a problem with the compiler, but I want to know what causes this situation. And what to do to make the results meet expectations.

            The code is as follow:

            ...

            ANSWER

            Answered 2021-Sep-16 at 16:51

            There are a couple of things that could be causing this:

            1. If you're timing your code, you should have:

            Source https://stackoverflow.com/questions/69211522

            QUESTION

            Bash, How to fix array processing, which only works with positive fieldindex?
            Asked 2021-Jul-17 at 15:48

            The following is a code example of the question which numbers can be generated in an adjustable range. The range can be set so that only positive, only negative or positive and negative numbers can be output.

            In the example, the output numbers are passed to an array and when the array is output, the number of times each number occurs is output.

            In the example, the processing by the array only works for positive numbers, which is probably due to the fact that a bash array can only have a positive and no negative field index.

            ...

            ANSWER

            Answered 2021-Jul-17 at 14:36

            Associative arrays allow arbitrary strings as indices. Here, I also took the liberty to change your 2nd loop to (( i=ug; i<=og; i++ )), which seemed more reasonable.

            Source https://stackoverflow.com/questions/68421041

            QUESTION

            Cross compile mosquitto with existing openssl version on armv7
            Asked 2021-Feb-19 at 16:14

            I've (so far) failed to successfully cross compile mosquitto with TLS for an embedded armv7 device. Without TLS, cross compilation works fine.

            Embedded Device Data:

            ...

            ANSWER

            Answered 2021-Feb-19 at 16:14

            Your target may not have dedicated hardware for encryption, and you therefore may not have any openssl crypto-engine implementation available on your platform, nor a version of openssl compiled with support for crypto-engines.

            You can check by executing ls: /usr/lib/engines-1.1, since this is the location specified in the output for the openssl version -a command you executed. If no dynamic libraries are present, or the directory does not exist, this is likely that you don't have any support for crypto-engines currently available on your system.

            In this case, you will have to re-build mosquitto with the CFLAGS=-DOPENSSL_NO_ENGINE option, so that mosquitto will not attempt to load any (non-existing) openssl crypto-engine at startup.

            Source https://stackoverflow.com/questions/66277415

            QUESTION

            Difference between RANDOM and SRANDOM in Bash
            Asked 2020-Dec-31 at 18:18

            Bash 5.1 introduces SRANDOM variable, but does it make any difference when used like this?

            ...

            ANSWER

            Answered 2020-Dec-31 at 18:18

            RANDOM (16-bit) vs SRANDOM (32-bit); 32-bit => much bigger random numbers (ie, more random numbers).

            As for the randomness of the 2x variables ...

            Try running:

            Source https://stackoverflow.com/questions/65523749

            QUESTION

            Understanding this shell scripting assignment
            Asked 2020-Mar-05 at 17:55

            I need some help understanding this Linux programming assignment. I have to use this C program that will randomize a text file and here is the program:

            ...

            ANSWER

            Answered 2020-Mar-05 at 01:11

            That block of script code sets the variable SHUF to the program you should use to shuffle a file. Either it will be the system's shuf program or your teacher's shuffle program.

            After the code is done, you can use $SHUF to run whichever program was found.

            Source https://stackoverflow.com/questions/60536668

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install srandom

            To build & compile the kernel module. A pre-req is "kernel-devel". Use yum or apt to install. To load the kernel module into the running kernel (temporary). To unload the kernel module from the running kernel. To install the kernel module on your system (persistent on reboot). To uninstall the kernel module from your system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/josenk/srandom.git

          • CLI

            gh repo clone josenk/srandom

          • sshUrl

            git@github.com:josenk/srandom.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link