I think in ur case you need only to hash and not to encrypt.The benefit of using SHA algorithms is to secure your encoded data. You will only need to store the resulting string after applying SHA algorithms which is 160 characters in the case of SHA1. you won't need 1,000,000,000 bytes to store them. The use of SHA algorithms is to transform any arbitrary length string into a fixed length string and thus if your strings are 1,000,000,000 characters long for example. In more clear words, you need to use RSA with a hashing algorithm such as SHA1 in the previous example. There is a very clear example in the bottom of this MSDN reference 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. Your choice of encryption algorithm will depend on what you're trying to do, and I'm no expert on that, I'm afraid.)ĮDIT: If you only need a hash, then other questions come into play. (Use MSDN to find details of each step, and feel free to ask for help in a specific part. Decode the relevant section of the plaintext binary as UTF-16 text.Find the length from the first or last byte.Decrypt the binary data (back to "plaintext" binary).Convert the base64 text to the encrypted binary data using Convert.FromBase64String.Convert the result to base64 using Convert.ToBase64String.Encrypt the binary data (which will always be 33 bytes).Add an extra byte at the end (or start) indicating the original length.Encode the string as binary using UTF-16 (which will always give the same byte array length for the same string input).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): It would help if you could clarify the question to confirm this or explain what you do want if this isn't it.) (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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |