C# Sign, wodCrypt Verifies signature - WeOnlyDo Discussion board

C# Sign, wodCrypt Verifies signature (wodCrypt)

by wodSupport, Monday, January 17, 2005, 03:09 (4692 days ago)

This code snippet shows interoperability between NET C# (signs data) and wodCrypt code (verifies signature).

Code to sign text ABCD with key stored as XML (exported by C#, can be loaded by wodCrypt): [code] String privateKey = <RSAKeyValue><Modulus>26NtFkEYNumpdM9/1Ie+TnoBaOCi6ZtGdrfFcFP7Aq/0zSt2iLPeu1mIwpO4x445mdsm3D+R5fgF/5bdSXPmh7QpeElG5GbkCO6YnLRoktOLu2TtEME59ripyMVeM8xahJj+8BnkKsZrwj2mPFlYxmc+DBIuRGm3f8FfDf5kpmc=</Modulus><Exponent>AQAB</Exponent><P>7p6tANYwpDzObpAq5sJiBJA01DuDA89ZpcO6t3JGf8q+kp5gcq5sgwfqVvxHgjCP3kN1IdXLs4zLVjVm+VGpfQ==</P><Q>66LSIRclT3mcWJkqiRj3gxeKIuQZ6KyPMJZqZGGcp3uwHblJr1bJrlLsqz2RwDdnmIhuEWM5gOCdl93lQ8D0sw==</Q><DP>oJ5qcY+7ujG7+qxMVHwvoka3aMyOSfg+rdfsTSM81TRRxzuYTFmgbSrc0KSMNdQeY0whAh95OGjjTiowIE6ZuQ==</DP><DQ>OWtpzQp42w8FXEmmpdXhqp432RzAe4RhODPPJTrsE5v+ZJ/cJs/9QW+PoILWW4KkyfSk7bPCNXeGr5Uw4vvIJQ==</DQ><InverseQ>K/ekbIbFzWufoBbhJz1U/8+XWXCei5og/tWyhvWLsaFnushtRzU8k92/VI9F+CHtHoEjwHtZaalRNoL1zoVvxQ==</InverseQ><D>Sky8qFyY7mqZEpTnL2REMpP/ShVDxzbp3VtJhThDn6MacxWS4afHXyVoqDoEti0cuzlxqewvVNZUYSQN870rbHhMivKOzyuTcP7yG+/Kvmk31LroV5jOOjAmtLyzt5hAdTDg9UBmweJzeL//aH3oNHkOhVj3KczDJXmRFRhqwbE=</D></RSAKeyValue> ;
CspParameters cspParam;
cspParam= new CspParameters();
cspParam.Flags = CspProviderFlags.UseMachineKeyStore;
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(cspParam);
String str = ABCD ;
RSA.FromXmlString(privateKey);
byte[] StrAsByte= System.Text.Encoding.Default.GetBytes(str);
byte[] SignedStrAsByte = RSA.SignData(StrAsByte, MD5 );
string SignIt= System.Convert.ToBase64String(SignedStrAsByte);[/code]Result: [code] IRH1ZMSKABNYFS/NRIIrG9LJ03aQ3oQ3qifW9qjI0tdJO/cDCP+f4FLUKCzoRpHb7hkoJpy9yKUX6nhQCtKd/sL9WfYbZwbKhB0oVja/qrN3XprFcqi+qLZ9qcbibkLT1hiJiDCUxCg61sGwfTjEoINcVX/4T4CxveSH1HKzDZI= [/code]


Complete thread: