string encryption

Mike Parker via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 1 21:09:35 PDT 2016


On Saturday, 2 July 2016 at 01:31:17 UTC, Hiemlick Hiemlicker 
wrote:


> But you are declaring string 1 and string 2 an enum. If you 
> declare them as a string then the original is embedded in the 
> binary!
>
> I don't know why that would change anything but it does.
>
> The reason it matter is because if one wanted to do a quick 
> change of strings from normal to encrypted, they would also 
> have to change all string variables to enums.
>

This is known as a manifest constant [1]:

enum myVal = 10;

When the compiler encounters any use of myVal, it will insert its 
value directly at the point of usage. myVal will not appear in 
the data segment. You cannot take its address.

[1] http://dlang.org/spec/enum.html#manifest_constants


More information about the Digitalmars-d mailing list