Would you hardcode a Rot13 string in a DLL?
What do you think, if you were doing Rot13, would you do something like this:
Code:
string abFrom = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
string abTo = "NOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLM";
Or would you generate the respective strings as shown, for example, on this page? http://www.osix.net/modules/article/?id=70
The merits and demerits of Rot13 are not being discussed here, it's just a matter of... if it's an encoding-decoding mechanism as simple as Rot13, would you simply hardcode it or generate it?
Re: Would you hardcode a Rot13 string in a DLL?
Oh and if you have some links about the merits vs demerits of hardcoding such strings in a DLL, that'd be great. This does seem like somewhat vaguely murky water and it's as though doing either thing really doesn't matter.
Re: Would you hardcode a Rot13 string in a DLL?
For something like Rot13, I think it would be a good idea to hard code them as it future proofs whatever is encoded/decoded with your methods. if you dynamically generated them and somehow a new letter is added to our alphabet. Your code still works but none of the encrypted data can be decrypted.
Though I don't think I would hard code it via an actual string inside of a class. I would prefer to put them into some sort of configuration file.
Re: Would you hardcode a Rot13 string in a DLL?
I was kind of hoping I could figure this out (without having to ask) by the responses to the questions, but such is not the case, so I'm going to ask.
What is a Rot13 string?
Re: Would you hardcode a Rot13 string in a DLL?
ROTate the string 13 characters.... So A becomes A + 13, or N.....
I wouldn't hard code them.... especially as constants.... any one with a decent Notepad could open the file and see the strings, and figure out the Rot13....
-tg
Re: Would you hardcode a Rot13 string in a DLL?
Quote:
Originally Posted by Hack
What is a Rot13 string?
http://en.wikipedia.org/wiki/ROT13
Re: Would you hardcode a Rot13 string in a DLL?
I wouldn't hard code it because you can see it with notepad - but if I had to hard code it I would do so as a single interleaved string for faster lookups.
Code:
string abAll = "ANBMCODPEQFRGSHTIUJV....