473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Crypto with Digital Certificate

Hello Group..
Someone have a sample to how crypt a string using Crypto API with digital
certificate ?

If someone have a sample and can send to me :)

Best Regards

Leandro Delamare
Nov 15 '05 #1
1 2484
Here's an example where you read a certificate from a local cert store and
use it to sign some data. It's easy to modify it so you can encrypt/decrypt.

I hope this helps,
-JG
/********************
* Cryptographer.cs *
********************/

using System;
using System.Security.Cryptography;
using Microsoft.Web.Services.Security.X509;

namespace Cryptomaniac {
public class Crytographer {
static void Main(string[] args) {
RSACryptoServiceProvider rsa;

// open the store
X509CertificateStore store =
X509CertificateStore.LocalMachineStore("MyStore");

store.OpenRead();

// get the cert
X509CertificateCollection ccol =
store.FindCertificateBySubjectString("Test cert");

X509Certificate cert = ccol[0];

// construct the RSA object with which to sign the data
rsa = (RSACryptoServiceProvider)cert.Key;

// get the bytes from the message (args[0] is the message)
byte[] msg_bytes = System.Text.Encoding.ASCII.GetBytes(args[0]);

// sign the data
byte[] signature = rsa.SignData(msg_bytes, "MD5");

// show the data as a Base64 string
Console.WriteLine("Signature: {0}",
System.Convert.ToBase64String(signature));
}
}
}
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Guangxi Wu | last post by:
Hi all, Happy New Year. I am using SignedXML and an X509 certificate to digitally sign a SOAP message body and put the signature in the SOAP header for a B2B business application. Can you...
0
by: Randy Harris | last post by:
How does one obtain a Digital Certificate? Apparently in A2K3, the user will always see a security warning (unless Security is set to Low) unless the code contains a Digital Signature. (Got all...
6
by: Matt Frame | last post by:
I have a client that has asked us to get a digital signature certificate and start digitally signing all files we pass between each other. I have heard of the subject and know about the certs but...
0
by: Bryan Slatner | last post by:
I'm having some difficulty finding the information I need. Maybe someone can point me in the right direction. I need to call methods on a web service defined by one of our vendors. They require,...
0
by: Arnie | last post by:
"We use an Authenticode (digital code signing) certificate from Verisign to digitally sign our .NET assemblies, and to ensure the assemblies in a calling tree are authentic as each class and public...
1
by: UnkleVo | last post by:
I have a winform app that is consuming WebService via SSL connection. We installed the digital certificate for that and the winform app is loading that cert at run time. Code in VB.net looks...
0
by: CHC | last post by:
Hi, I would like to verify the authenticity of a X509 digital certificate. I'm using Crypt::X509 to create a certificate object and can extract the data fields. But, I can't find a way to verify...
1
by: =?Utf-8?B?RWRkaWUgTGFzY3U=?= | last post by:
Not sure this is the right place to ask my question, please bear with me. After reading the question, if you think there should be a different place let me know. I need to automate a daily...
5
by: troy_lee | last post by:
We have an application developed by one developer. He compiled the database into an application and digitally signed the application. He doesn't know if he used selfcert of makecert to make the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.