There is no such thing. All encryption is done on binary data, i.e. bytes
, and the result is binary data, i.e. bytes
. That's it, that's all. You can then convert the result bytes to a string if you want, using hexadecimal or base 64, but that's an extra step.
The only way you could do what you want is if you could use an encryption method that would output the exact amount of binary data needed to represent a DateTime
. You would then convert one value to bytes, encrypt that, then convert the result to a DateTime
. The DateTime.ToBinary
and .FromBinary
methods work with 64-bit numbers, so if you can find a way to encrypt 8 bytes to 8 bytes then you're good to go. Otherwise, you're screwed.