complexity theory – Why does a polytime hitting set generator derandomize RP?

I am reading Goldreich, Vadhan, Wigderson: Simplified Derandomization of BPP Using a Hitting Set Generator and trying to understand the result that polytime hitting set generators (HSGs) would not only imply $mathsf{RP = P}$ but $mathsf{BPP = P}$ as well, but I can’t even conceptualize why the former holds.

The paper states that

Having such a generator that runs in polynomial time enables a trivial deterministic
simulation of an RP algorithm by using each of the generator’s outputs as the random pad
of the given algorithm.

Every paper or lecture notes I’ve found on the topic of HSGs and $mathsf{BPP}$ derandomization also mentions that $mathsf{RP}$ derandomization is trivial using an HSG, simply by trying all elements of the hitting set as random pads.

I am confused as to why this is the case. At least one element of a hitting set must be accepted by circuits that accept over half of their inputs. However, RP circuits don’t necessarily accept over half their inputs; rather, if $x in L$, only then will the circuit accept over half the time. I assume that fact is related to why a hitting set must contain a valid $mathsf{RP}$ random pad, but I do not understand exactly how.

So, my question is: how do the circuits in the definition of an HSG relate exactly to $mathsf{RP}$ circuits? i.e. how do the elements of the hitting set – which are to be the random pads across all inputs – relate to the randomness of RP algorithms when such algorithms accept over half the time only when $x in L$?

project – How to make a flowchart to code generator

this is my first question ever on stackoverflow and i am kind of a newbie here and in programming too so please excuse me if i make any mistakes.
Okay so my question is i want to make a project on to convert a flowchart of an algorithm into a working code in a few programing languages (for ex, c,c++,java,python etc). Something like what flowgorithm does in a nutshell. If i want to make something similar like that, how must i proceed?

python – imap on generator object without monkey patch?

I am processing an unknown “length” of generator object.
I have to keep things “lazy” because of memory management.
The processing is compute heavy, so writing it multiproc style is the solution (or at least it seems for me).

I have solved this problem of multiproc on generator object with a combination of monkey patch and a bounded Queue.

What really itches me is the monkey patch…
Do you think this is fine to apply imap on a generator object? How would you do this?

I would like to underline that the focus is to compute the outputs of a generator in parallel.
From the perspective of this “minimal example” :

process_line, process_line_init, process_first_n_line

are the functions I am most interested about your opinion.

import multiprocessing as mp
import psutil
import queue 
from typing import Any, Dict, Iterable, Set

def yield_n_line(n: int)-> Iterable(Dict(str, str)):
    for i in range(n):
        yield {'body': "Never try to 'put' without a timeout sec declared"}

def get_unique_words(x: Dict(str, str))-> Set(str):
    return set(x('body').split())

def process_line(x:Dict(str, str))-> Set(str):
        process_line.q.put(x, block=True, timeout=2)
    except queue.Full:
    return get_unique_words(x)

def process_line_init(q: mp.Queue)-> None:
    process_line.q = q

def process_first_n_line(number_of_lines: int)-> Any:
    n_line = yield_n_line(number_of_lines)
    if psutil.cpu_count(logical=False) > 4:
        cpu_count = psutil.cpu_count(logical=False)-2
        cpu_count = psutil.cpu_count(logical=False)
    q = mp.Queue(maxsize=8000)
    p = mp.Pool(cpu_count, process_line_init, (q))
    results = p.imap(process_line, n_line)
    for _ in range(number_of_lines):
        except queue.Empty:

def yield_uniqueword_chunks(
    n_line: int = 10_000_000,
    chunksize: int = 1_787_000)-> Iterable(Set(str)):
    chunk = set()
    for result in process_first_n_line(n_line):
        if len(chunk) > chunksize:
            yield chunk
            chunk = set()
    yield chunk

def main()-> None:
    for chunk in yield_uniqueword_chunks(
        n_line=1000, #Number of total comments to process
        chunksize=200 #number of unique words in a chunk (around 32MB)
if __name__ == "__main__":

python – How can I make this code for a password generator better?

I am pretty new to programming but want to get into it. The password generator here takes user input and checks whether the password that was entered is valid or not. Based on that, a reply is printed.
This is the code:

print("Create a password! Your password must have 8 to 12 digits. Numbers and lower as well as upper case letters must be a part of it!")
password = input("Enter your password:")
res = any(chr.isdigit() for chr in password)
res2 = any(chr.islower() for chr in password)
res3 = any(chr.isupper() for chr in password)
if len(password) >= 8 and len(password) <13 and res == True and res2 == True and res3 == True :
    print("Your password is not valid!")

If somebody is willing, can you please give me some pointers on how to do this in a more elegant or generally better way? Maybe, you also have some ideas on how to expand the project?

pseudo random number generator – Is there a way to programatically generate new hash functions that are secure?

Is is possible to programatically generate diffrent hash functions? Of course it is. We can simply tweak the numerical parameters of the hash function. But is there a known way to generate secure hash functions programatically? I got an idea for a new authentication system but it relies on using a hash function that MUST be unknown to the attacker. I want the attacker to not be able to try every KNOWN hash function on planet Earth and break the security.

The idea is the following. I want to be sure someone that someone is who they claim to be. All I know is their initial “name” and a hash function. The name can be any string of fixed length. They hash the name with the hash function and send it to me. I can verify that they are who they claim to be. How ? I hash the initial name and chech wehther the result is the same with their hash. The next time we connect the same procedure is repeated only this time we use the new hash as the source.
Obviously there is a problem if we use a common hash function such as SHA 256 as the attacker can easily try different functions on the name until he gets the same hash. That’s why I need to be able to generate a unique hash function that the attacker cannot easily guess.

Need a small generator made $3 paypal as friend

i need the format like this
original data will be on one line , delimiter " i paste my data in a text area and hit the button

Code (markup):

i need to generate one per line format

java brain wallet generator that can generate segwit addresses (bc1)

I found a JavaScript program that does exactly what I want.
Can anyone help with translating it to Java.

Very grateful in advance

let bitcoin = require('bitcoinjs-lib');
let assert = require('assert')
let bigi = require('bigi')

let NETWORK = bitcoin.networks.bitcoin;
let brainwallet = "This is my brain wallet and it is less secure than a CSPRNG source";
let hash = bitcoin.crypto.sha256(brainwallet);
let d = bigi.fromBuffer(hash);
let nkeyp = new bitcoin.ECPair(d);
let wif = nkeyp.toWIF();
let pubKey = nkeyp.getPublicKeyBuffer();
let scriptPubKey = bitcoin.script.witnessPubKeyHash.output.encode(bitcoin.crypto.hash160(pubKey))
let address = bitcoin.address.fromOutputScript(scriptPubKey);

add a pdf generator [closed]

here is my question. in a custom module i want to add a button which returns a pdf file (with records from database). I can’t use composer cause of using shared hosting. any ideas how can add this button. I’m a newbie in programming so please, may someone explain from start till the end.
what kind of library better to use and how to use it without composer and etc.

java – Strong password generator with symbols that user definies

I’ve created program like in the title. Actually I know I could use regex to create pattern and then do some actions from it, but I think my code is clear enough (at least for me :P). There is a little thing to correct which is InputMismatch exception that isn’t handled. What do you think about my code?

import java.util.Scanner;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

public class PasswordGenerator {
    //arrays with optional symbols
    private final char () symbols = {'~', '`', '!', '@', '#' , '$', '%', '^', '&', '*', '(', ')', '_', '-', '=', '+',
            '(', '{', ')', '}', '\', '|', ';', ':', ''', '"', ',', '<', '.', '>', '/', '?'};

    private final char () lowerCaseChars = {'a' , 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
            'p', 'q' , 'r', 's', 't', 'u', 'v', 'w', 'x', 'y' , 'z'};

    private final char () upperCaseChars = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
            'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};

    private final char () numbers = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

    //methods asking about external symbols
    private static boolean wantsSymbols(String kind, String example) {
        Scanner input = new Scanner(;
        System.out.print("Do you want " + kind + " in password like " + example + "?(Y/N) ");
        char in =;
        return in == 'Y' || in == 'y';

    //return random value from specified array
    private static char randValue(char() arr) {
        Random rand = new Random();
        return arr(rand.nextInt(arr.length));

    //combine the random values
    private static char() combineRandomValues(int length, char() array) {
        char () returnedArray = new char(length);
        for(int i = 0; i < length; ++i) {
            returnedArray(i) = randValue(array);
        return returnedArray;

    //combine arrays
    private static char() combineArrays(char()arr1, char()arr2, char()arr3, char()arr4) {
        StringBuilder sb = new StringBuilder();
        if(arr1.length > 0)
        if(arr2.length > 0)
        if(arr3.length > 0)
        if(arr4.length > 0)
        return sb.toString().toCharArray();

    //from long array take random value
    private static char pickRandomValuesFromLongArray(char() longArray) {
        int randomNumber = ThreadLocalRandom.current().nextInt(0, longArray.length);
        return longArray(randomNumber);

    private static String generatePassword(boolean inclSymbols, boolean inclLower,
                                           boolean inclUpper, boolean inclNumbers, int length) {
        //created object to use the arrays with values
        PasswordGenerator obj = new PasswordGenerator();

        //using string builder to create password
        StringBuilder sb = new StringBuilder();

        //arrays for random values
        char () sArray = new char(0);
        char () lArray = new char(0);
        char () uArray = new char(0);
        char () nArray = new char(0);

        //take first letters of bool
        char symbolsBool = String.valueOf(inclSymbols).toLowerCase().charAt(0);
        char lowerBool = String.valueOf(inclLower).toLowerCase().charAt(0);
        char upperBool = String.valueOf(inclUpper).toLowerCase().charAt(0);
        char numbersBool = String.valueOf(inclNumbers).toLowerCase().charAt(0);

        if(!inclLower && !inclNumbers && !inclUpper && !inclSymbols) {
            System.out.println("You've to at least include one type of symbol");

        if(symbolsBool == 't') {
            sArray = combineRandomValues(length, obj.symbols);
        if(lowerBool == 't') {
            lArray = combineRandomValues(length, obj.lowerCaseChars);
        if(upperBool == 't') {
            uArray = combineRandomValues(length, obj.upperCaseChars);
        if(numbersBool == 't') {
            nArray = combineRandomValues(length, obj.numbers);

        //combine array 4 arrays from before
        char() combinedArray = combineArrays(sArray, lArray, uArray, nArray);

        for(int i = 0; i < length; ++i)

        return sb.toString();

    public static void main(String() args) {
        Scanner input = new Scanner(;
        int lengthOfPass;
        //variables specifying the complexity of password
        boolean inclSymbols, inclLowercaseChars, inclUppercaseChars, inclNumbers;

        while (true) {
            System.out.print("Password length from 6 to 128: ");
            lengthOfPass = input.nextInt();
            if (lengthOfPass >= 6 && lengthOfPass <= 128) {
            else {
                System.out.println("Try again");
        //questions about symbols
        inclSymbols = wantsSymbols("symbols", "$,#,@ etc.");
        inclLowercaseChars = wantsSymbols("lowercase characters", "a,b,c...");
        inclUppercaseChars = wantsSymbols("uppercase characters", "A,B,C...");
        inclNumbers = wantsSymbols("numbers", "0,1,2,3...");

        //initialize and output password
        String password = generatePassword(inclSymbols, inclLowercaseChars, inclUppercaseChars, inclNumbers, lengthOfPass);
        System.out.printf("n%s", password);

Also I know that I don’t hold same structure (e.g. char () … and char() …)