Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Can I define my own characters in a programming language such as C# or C++?
I'm trying to write an encryption algorithm.
My best idea is that for every new word it processes, the program will define a new character.
For example, if it finds the word "cat" (and it didn't meet it before) the program will define a new character, such as ä, į or ø
So my question is: can an algorithm define new characters?
3 Answers
- ChrisLv 76 years ago
That's not going to work in the long run, because for longer messages the algorithm will run out of characters.
In the meantime, just provide the program with an array of characters and manually list all the special characters you want to use. Then make the program increase the index by one whenever it encounters a new word.
Again, if you just want to practice programming, go ahead. If this is supposed to be productive, go back to a per character encryption.
- ?Lv 76 years ago
Sure, it's called a dictionary or hash. In Ruby...
a = [1, 2, 3, 4, 5]
b = ['a', 'b', 'c', 'd']
Hash[a.zip(b)]
=> {1=>"a", 2=>"b", 3=>"c", 4=>"d", 5=>nil}
You can replace any of those symbols (left or right) with any other symbols depending on the language. With the C family of languages I'm not so sure. But, if a person were smart regardless of language, they would triple encrypt it, meaning encrypt the message and the dictionary too along with the code to encrypt and decrypt.
- Anonymous6 years ago
Most likely so if you include the 110,000 unicode characters covering 100 scripts. And if you sub two unicode characters instead of one for each word you increase the "vocabulary" size by a very large factor. You are not defining new characters. Here is a sample I hope they show: Δ, Й, ק, م, ๗, あ, 叶, 葉, and 말.