Search code examples
c#encryptionbase64sha1

Encryption, possible base64?


Given the string

KlVkeNK76V27D2MSBOhfNC6eNtA=

This look like base64 encoded. However, I tried using convert to base64 with C# , result is a garbage string.

public static string Base64Encode(string plainText)
{
   var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
   return System.Convert.ToBase64String(plainTextBytes);
}

If I use this:

https://hashkiller.co.uk/sha1-decrypter.aspx

then it give a nicely SHA1 hash:

2a556478d2bbe95dbb0f631204e85f342e9e36d0

Can anyone show me how to decrypt it with C#? Thanks a lot.


Solution

  • They simply print the hex value of the base64-decoded string:

    byte[] bytes = Convert.FromBase64String("KlVkeNK76V27D2MSBOhfNC6eNtA=");
    string hexString = new SoapHexBinary(bytes).ToString().ToLowerInvariant();
    

    (where SoapHexBinary is a .NET class that converts byte[] to hex string)