Vitaliy ◀️TriΔng3l▶️
??
jk :D
Nicola
i don't understand
Vitaliy ◀️TriΔng3l▶️
But time returns time in seconds
Nicola
milliseconds
Vitaliy ◀️TriΔng3l▶️
milliseconds
https://linux.die.net/man/2/time
Vitaliy ◀️TriΔng3l▶️
milliseconds
and even within one millisecond you can do A LOT of stuff
Nicola
sorry
Vitaliy ◀️TriΔng3l▶️
So if you call srand(time(NULL)) multiple times within one second, the RNG will be initialized to the same value
Nicola
so how can I solve?
Vitaliy ◀️TriΔng3l▶️
so how can I solve?
Initialize the RNG only once, or use less predictable seeds guaranteed to be different
Vitaliy ◀️TriΔng3l▶️
Though using C rand is not a good idea for cryptography
Nicola
what's the RNG?
Vitaliy ◀️TriΔng3l▶️
what's the RNG?
Random number generator
Vitaliy ◀️TriΔng3l▶️
I mean, don't call srand twice
Vitaliy ◀️TriΔng3l▶️
why?
It's predictable
Vitaliy ◀️TriΔng3l▶️
https://wiki.sei.cmu.edu/confluence/display/c/MSC30-C.+Do+not+use+the+rand%28%29+function+for+generating+pseudorandom+numbers
Vitaliy ◀️TriΔng3l▶️
https://crypto.stackexchange.com/questions/15662/how-vulnerable-is-the-c-rand-in-public-cryptography-protocols
Vitaliy ◀️TriΔng3l▶️
rand will always return the same sequence for equal values passed to srand
Vitaliy ◀️TriΔng3l▶️
Cryptographic random number generators behave more randomly
Nicola
ah ok perfect 😂,now I search another function to generate a key aahah
Nicola
Can you suggest something? @Triang3l
Vitaliy ◀️TriΔng3l▶️
Can you suggest something? @Triang3l
The wiki.sei.cmu.edu page I sent has some code for both Linux and Windows
Mihail
Vitaliy ◀️TriΔng3l▶️
Not sure how secure the Linux implementation there is, but the Windows one uses the crypto library of Windows
Nicola
c++
Nicola
I use the Windows as operation system ahah
Mihail
c++
Why not just use std::mt19937?
Mihail
Iirc only the 10000th cycle is predictable or something like that
Mat
There's /dev/random on linux
Mat
It's neat
Mihail
There's /dev/random on linux
He said he's using Windows tho
Mihail
https://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine
Mihail
This should have all the info you need
Mihail
@NICOOH
Mat
https://stackoverflow.com/questions/191335/windows-equivalent-of-dev-random
Mihail
Not portable as?
Well even if you code in Windows I don't see a point in using Windows APIs just because it's there
Nicola
https://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine
I don't know how to use it. Is there an example of syntax?
Mihail
I don't know how to use it. Is there an example of syntax?
https://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution
Mihail
There is an example there
Nicola
https://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution
sorry for the ignorance, but can I use namespace std?
Mihail
sorry for the ignorance, but can I use namespace std?
You mean can you do using namespace std;?
Nicola
Yes
Mihail
Yes you can, but you probably shouldn't
Mihail
But yes
Mihail
Just remove the std:: prefix
Francisco
Yes I know
In the end, it's not that big of a deal to append std::
Dima
hm
BinaryByter
In the end, it's not that big of a deal to append std::
But it saves you from many problems in the long run
olli
*prepend [ not append :) ]
Ludovic 'Archivist'
CryptGenRandom() is the way to go on windows
Nikhil
M
Hello
M
I'm new membre 😊✌🏼
Talula
Welcome @Thehatem Please read the pinned message 😞
BinaryByter
BinaryByter
## Rules #pinned * You are not entitled to an answer, getting angry about not answered questions will get you warned. * Not checking your problem in google (or any other search engine) first will get you a warn. * Asking for something that is in the pinned message right after joining WILL GET YOU BANNED. * C/C++ discussion preffered (assembly also allowed), asking about other languages (or groups for other languages) right after joining will get you BANNED. * Reverse enginnering, hacking and related topics are allowed, but asking to hack facebook, instagram, etc. is NOT allowed. Also if you ask "how to become a hacker" and obviously have zero knowledge on anything related to that you may get warned or banned. * Legitimate requests for help on code and programming questions are welcome. A request is considered legitimate if it describes your problem, what you've done so far and what went wrong. Requests such as "write my program" or "do my homework" are never considered legitimate. Asking not legitimate questions will result in a warn or ban. See https://stackoverflow.com/help/mcve on how to write good questions. * Asking for book recommendations is ok, but "pls give pdf book" is not allowed, find books by yourself. Posting illegally copied books (or links to those books) is also not allowed. * Only English language is allowed, if you speak shitty English or don't understand anything in English YOU WILL BE BANNED. * A little bit of programming related memes, jokes, shitposting are allowed. * NSFW content (porn, nudity, etc.) is not allowed. * Spamming/advertising (job posts are also ads, so ask an admin before posting) will grant you a warning or an immediate ban if you do it right after joining. * Religion, politics and ideological topics are forbidden. * Long code snippets must be posted via a snippet website(links below), posting pictures of code and posting long snippets in the group is not allowed. * If you encounter a problem, while using turbo C++, you will not be helped, use another more modern IDE. * Don't post compiled executables, that is obviously a security risk ## Resources About asking good questions: * [English](http://www.catb.org/esr/faqs/smart-questions.html) * [Translations](http://www.catb.org/esr/faqs/smart-questions.html#translations) For posting long code snippets: * [GitHub Gist](https://gist.github.com) * [Ubuntu Paste](https://paste.ubuntu.com/) * [Pastebin](https://pastebin.com) ## Reports If you notice any forbidden content, please use the /report command while responding to the offending post to report it to the admins.
I LOVE the last point, tbh
cutout
#cbook
Anonymous
Writing a music player in c ++ What things I need to learn
Mat
Writing a music player in c ++ What things I need to learn
How to write a music player :P Probably how to read and write files, how to manage a music stream, how to manage music files and other things
MᏫᎻᎯᎷᎷᎬᎠ
But I think every music file format has its own stream
MᏫᎻᎯᎷᎷᎬᎠ
You should learn that one first
Talula
Writing a music player in c ++ What things I need to learn
Why in the world would you write a Music player in C++? It's a better idea to use C# or some higher level language like Java to write a complex GUI.
MᏫᎻᎯᎷᎷᎬᎠ
MᏫᎻᎯᎷᎷᎬᎠ
Like music.getPath("path") music.play()
MᏫᎻᎯᎷᎷᎬᎠ
I hate that