Question : How do I encrypt a string so that it is suitable to be a filename?

Hello,

I have a string whose pattern is : #######_#_########_######_### (example: 1001046_1_20091215_143825_734)

What I need to do is encrypt this string and use it as a filename. For this, I found this library : http://www.codeproject.com/KB/security/encryption_decryption.aspx

It supports DES, RC2, Rijndael encryptions. But when I encrypt a string with a key defined by me, I see that some of the results can include a slash character ("/") with all the methods (example : zet4xIHpIrYKoAolEGJcnhgx/rn0bYWLz3Svh266Mmg=). So the encrypted string is not suitable to be a filename.

Which encryption method should I use to get a string that can be suitable to be a filename?
Can anyone help?

Thank you,
Afsar.

Answer : How do I encrypt a string so that it is suitable to be a filename?

You could use an MD5 hash.. do you need to be able to decrypt it or is it simply to create a unique identifier?

Or, you could convert the output to HEX then you'd have no dodgy characters.

If you're looking to encrypt for the purposes of security, then you need to make a careful choice about the algorithm (DES for example, would not be considered acceptable for most applications because it can be easily cracked).
Random Solutions  
 
programming4us programming4us