المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Java to C#



C# Programming
10-01-2009, 10:00 PM
Hi I've few Java code and want to convert exact C# code can anybody help me out?




public static String calculateRFC2104HMAC(String data, String key, String signatureMethod)
throws SignatureException
{
String result = "";
try
{
SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), signatureMethod);
Mac mac = Mac.getInstance(signatureMethod);
mac.init(signingKey);
byte rawHmac[] = mac.doFinal(data.getBytes());
result = Base64.encodeBytes(rawHmac);
}
catch(Exception e)
{
throw new SignatureException("Failed to generate HMAC : " + e.getMessage());
}
return result;
}