Hi! โ๏ธ I need to generate some string in C++ with random characters that can use all letters from "a" to "z" (include capital letters), and all numbers from 0 to 9 there.
And for examples this should looks somehow like this:
SnHXAsOC5XDYLgiKM5ly
Also I want to encrypt that string then by itself:
SnHXAsOC5XDYLgiKM5ly encrypt with SnHXAsOC5XDYLgiKM5ly key.
So, how can I do this in C++? ๐ค
Thanks in advance!
17 Comments
bunitor@lemmy.eco.br · 4 pts · 1y
you can do this in pretty much any language. have you tried anything and need help or you're just asking us to do your homework for you?
xolatgames@programming.dev · -1 pts · 1y
Asking to do a homework.
bunitor@lemmy.eco.br · 2 pts · 1y
honest advice: it's fine to ask for help online, but not putting any effort into solving your own problems before you do is disrespectful
xolatgames@programming.dev · -1 pts · 1y
I think that doesn't respectful to stay in this community for myself. Have a nice day! โ๐ผ
pelya@lemmy.world · 3 pts · 1y
bunitor@lemmy.eco.br · 2 pts · 1y
that's cheating
(also, it won't work on systems without curl installed)
lambalicious@lemmy.sdf.org · 1 pts · 1y
(or without internet access)
xolatgames@programming.dev · 2 pts · 1y
๐คญ
herzenschein@pawb.social · 2 pts · 1y
You could take inspiration from Theodore Tso's pwgen: https://github.com/tytso/pwgen
It's a Unix utility in C commonly used on Linux and FreeBSD to make truly random passwords. It's the first thing I thought of when reading this.
xolatgames@programming.dev · 1 pts · 1y
It will be a really hard work https://github.com/tytso/pwgen/blob/master/pw_rand.c ๐ค
xolatgames@programming.dev · 1 pts · 1y
But thanks to you! ๐
xolatgames@programming.dev · 1 pts · 1y
xolatgames@programming.dev · 1 pts · 1y
xolatgames@programming.dev · 1 pts · 1y
Thanks so much! ๐๐ผ
lambalicious@lemmy.sdf.org · 1 pts · 1y
There are various ways to solve the first part and they're pretty generic, the only "
C++-specific" part is whether you'll want to build the string step by step (adding characters) or build in one go then modify (build a prearranged string, for example of a specific size, then modify as needed).To solve the second part we (you) also need to know the encryption algorithm. "Encrypt" is quite a generic word.
xolatgames@programming.dev · 2 pts · 1y
Let's solve the first part then.
But I guess that @herzenschein already suggested me a solution...
lambalicious@lemmy.sdf.org · 1 pts · 1y
Oh good I had forgotten that part!
xolatgames@programming.dev · 1 pts · 1y
What's the best encryption algorithm in your opinion?
Oisteink@feddit.nl · -1 pts · 1y
This is not doable in c++ unfortunately. Its an old case thatโs only doable in f# or turbo pascal because of string handling and cryptography export rules (and possibly copy right)