using System;
using System.Security.Cryptography;
public class Test
{
public static void Main()
{
Console.WriteLine(CriptSha1("teste"));
}
public static string CriptSha1(string secret)
{
string result = "";
byte[] key = System.Text.Encoding.UTF8.GetBytes(secret);
SHA1 sha1 = SHA1Managed.Create();
byte[] hash = sha1.ComputeHash(key);
foreach (byte b in hash)
{
result += b.ToString("X2");
}
return result;
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uU2VjdXJpdHkuQ3J5cHRvZ3JhcGh5OwoKcHVibGljIGNsYXNzIFRlc3QKewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJewoJCUNvbnNvbGUuV3JpdGVMaW5lKENyaXB0U2hhMSgidGVzdGUiKSk7Cgl9CgkKCXB1YmxpYyBzdGF0aWMgc3RyaW5nIENyaXB0U2hhMShzdHJpbmcgc2VjcmV0KQoJewoJCgkgICAgc3RyaW5nIHJlc3VsdCA9ICIiOwoJCgkgICAgYnl0ZVtdIGtleSA9IFN5c3RlbS5UZXh0LkVuY29kaW5nLlVURjguR2V0Qnl0ZXMoc2VjcmV0KTsKCQoJICAgIFNIQTEgc2hhMSA9IFNIQTFNYW5hZ2VkLkNyZWF0ZSgpOwoJCgkgICAgYnl0ZVtdIGhhc2ggPSBzaGExLkNvbXB1dGVIYXNoKGtleSk7CgkKCSAgICBmb3JlYWNoIChieXRlIGIgaW4gaGFzaCkKCSAgICB7CgkgICAgICAgIHJlc3VsdCArPSBiLlRvU3RyaW5nKCJYMiIpOwoJICAgIH0KCQoJICAgIHJldHVybiByZXN1bHQ7Cgl9Cn0=