Alguien qu eme ayude a trasnsformar este fuente de CSharp en una dll, ya que se me a echo un lio homologarla en delphi, asi si la logro transformar en dll compilando en CSharp la puedo llamar desde delphi.
se los agradeceria mucho a los que sean expertos en CSharp.
gracias de antemano..
Código PHP:
public static class VoiceCode
{
public static string Compute(string GTIN, string lot, DateTime? packDate)
{
ushort crc = Crc16.ComputeChecksum(Encoding.ASCII.GetBytes(string.Format("{0}{1}{2}", GTIN, lot, packDate.HasValue ? packDate.Value.ToString("yyMMdd") :
string.Empty))); return string.Format("{0:0000}", crc % 10000);
}
}
public static class Crc16 { #region static members
private const ushort polynomial = 0xA001; private static ushort[] table = new ushort[256]; static Crc16()
{
ushort value; ushort temp;
for (ushort i = 0; i < table.Length; ++i) {
value = 0;
temp = i; for (byte j = 0; j < 8; ++j) {
if (0 != ((value ^ temp) & 0x0001)) {
value = (ushort)((value >> 1) ^ polynomial);
} else {
value >>= 1; } temp >>= 1;
}
table[i] = value;
}
} #endregion
public static ushort ComputeChecksum(byte[] bytes) { ushort crc = 0;
for (int i = 0; i < bytes.Length; ++i) {
byte index = (byte)(crc ^ bytes[i]);
crc = (ushort)((crc >> 8) ^ table[index]);
} return crc;
}
}