How to make program that converts string's characters to random numbers? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to make program that converts string's characters to random numbers?

I wanna make a program that converts strings's characters into random numbers let me explain in details example: I wrote "baba" in the text field, I have assigned a random number for every character example for 'a' 1 to 5 and 'b' 6 to 10 so if I write 'baba', a program should give output '7283' the output should be different every time, as 'a' represents a number between 1 to 5 and 'b' represents a number between 6 to 10 This program also can be used for simple encryptions...

5th Jul 2018, 8:25 AM
Deep Patel
Deep Patel - avatar
7 Answers
+ 2
In c++ , it can help to hide small messages
5th Jul 2018, 9:03 AM
Deep Patel
Deep Patel - avatar
+ 4
Deep@Code You have to post some code (this prevent who want get homework maded from others). I think that you want "decript" also these messages and with this method you cannot do it (but you have missed some details)
5th Jul 2018, 9:07 AM
KrOW
KrOW - avatar
+ 1
Deep@Code You missed some info... Which language? Where is your current work code? Anyway i dont think that you can be encrypt something in this way
5th Jul 2018, 8:48 AM
KrOW
KrOW - avatar
+ 1
in python you can use like >>>import random >>>letters="a","b","c"... >>>RandomLetters=random.choice (letters) and now if you use like >>>print (RandomLetters) it will be random
6th Jul 2018, 2:13 AM
I Am Arthur
I Am Arthur - avatar
+ 1
hope u understand
6th Jul 2018, 2:13 AM
I Am Arthur
I Am Arthur - avatar
+ 1
in cpp you can use bit operators to create number from strings https://code.sololearn.com/csVlALL59Pa7/?ref=app
21st Aug 2018, 11:31 AM
Saeed Vahid
Saeed Vahid - avatar
5th Jul 2018, 9:00 AM
NizhamPihe
NizhamPihe - avatar