I'm not sure, since Microsoft did not bother to say which standard corresponds to their class, but I suspect that this NIST document that the Microsoft class computes using only triple DES instead of DES.
, , mcrypt.
1:
, , PHP #.
-, #:
using System;
using System.Text;
using System.Security.Cryptography;
namespace TDESMacExample
{
class MainClass
{
public static void Main (string[] args)
{
var keyString = "012345678901234567890123";
var keyBytes = Encoding.ASCII.GetBytes(keyString);
var mac = new MACTripleDES(keyBytes);
var data = "please authenticate me example number one oh one point seven niner";
Console.WriteLine(data.Length);
var macResult = mac.ComputeHash(Encoding.ASCII.GetBytes(data));
Console.WriteLine(BitConverter.ToString(macResult));
}
}
}
, PHP:
<?php
$data = 'please authenticate me example number one oh one point seven niner';
$key = '012345678901234567890123';
$iv = '\x00\x00\x00\x00\x00\x00\x00\x00';
$cipher = mcrypt_cbc(MCRYPT_3DES, $key, $data, MCRYPT_ENCRYPT, $iv);
$mac_result = substr($cipher, -8);
echo "mac result : " . bin2hex($mac_result);
echo "<br>";
?>