Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static string Encode(string text)
- {
- byte[] bytes = StringConvertToBytes(text);
- using (MemoryStream stream = new MemoryStream())
- {
- Write(stream, Compute<CriptoProvider1>(bytes));
- Write(stream, Compute<CriptoProvider2>(bytes));
- return BytesConvertToString(stream.ToArray());
- }
- }
- private static void Write(MemoryStream stream, byte[] hash)
- {
- stream.WriteByte(0);
- stream.Write(hash, 0, hash.Length);
- }
- private static string BytesConvertToString(byte[] bytes)
- {
- return Convert.ToBase64String(bytes);
- }
- private static byte[] StringConvertToBytes(string text)
- {
- return Encoding.Unicode.GetBytes(text);
- }
- private static byte[] Compute<T>(byte[] bytes)
- where T : HashAlgorithm, new()
- {
- return (new T()).ComputeHash(bytes);
- }
Add Comment
Please, Sign In to add comment