I want to encrypt string to base64, the string input can be in differential length(the limit is 16 charcters), and I want to get the encrypted string in fixed length.
Does anyone know about the way to do that in .NET framework? or has an algorithm to do that?
(EDIT: I've been assuming you want to both encrypt a string, and then encode the result as base64, always ending up with the same output length. It would help if you could clarify the question to confirm this or explain what you do want if this isn't it.)
Well, there's a pretty simply algorithm which would work given any encryption scheme which always encrypts an input of a fixed length to an output of a fixed length (and there are plenty of those):
Convert.ToBase64String
To decrypt, simply reverse the process:
Convert.FromBase64String
(Use MSDN to find details of each step, and feel free to ask for help in a specific part. Your choice of encryption algorithm will depend on what you're trying to do, and I'm no expert on that, I'm afraid.)
EDIT: If you only need a hash, then other questions come into play. Would you always want the same string to end up being hashed to the same string? That's typically desirable for hashing but not encryption.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With