资源简介
cea5e0d02f7fae173bec1bed4cf465e0.rar
代码片段和文件信息
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Math;
using Org.BouncyCastle.Math.EC;
using Org.BouncyCastle.Utilities.Encoders;
using System;
using System.Text;
namespace ChinaEncrypt
{
public class SM2Utils
{
// 默认私钥
string prik = “008890F1303B50AD04440C71819D2496BB7BE32DBC1AEA94B527D9ED1BFDCB0B5B“;
// 默认公钥
string pubk = “0426BA9D72A23F0906BB331B3116E5E3CB631A0C9DDDAAD86C4C30577BD4858F21E892487EE3212E28C3094049FA4BD49C7A83B56E667ED2EA9CCC4AE73EBCDE50“;
private String Encrypt(byte[] publicKey byte[] data)
{
if (null == publicKey || publicKey.Length == 0)
{
return null;
}
if (data == null || data.Length == 0)
{
return null;
}
byte[] source = new byte[data.Length];
Array.Copy(data 0 source 0 data.Length);
Cipher cipher = new Cipher();
SM2 sm2 = SM2.Instance;
ECPoint userKey = sm2.ecc_curve.DecodePoint(publicKey);
ECPoint c1 = cipher.Init_enc(sm2 userKey);
cipher.Encrypt(source);
byte[] c3 = new byte[32];
cipher.Dofinal(c3);
String sc1 = Encoding.Default.GetString(Hex.Encode(c1.GetEncoded()));
String sc2 = Encoding.Default.GetString(Hex.Encode(source));
String sc3 = Encoding.Default.GetString(Hex.Encode(c3));
return (sc1 + sc2 + sc3).ToUpper();
}
private byte[] Decrypt(byte[] privateKey byte[] encryptedData)
{
if (null == privateKey || privateKey.Length == 0)
{
return null;
}
if (encryptedData == null || encryptedData.Length == 0)
{
return null;
}
String data = Encoding.Default.GetString(Hex.Encode(encryptedData));
byte[] c1Bytes = Hex.Decode(Encoding.Default.GetBytes(data.Substring(0 130)));
int c2Len = encryptedData.Length - 97;
byte[] c2 = Hex.Decode(Encoding.Default.GetBytes(data.Substring(130 2 * c2Len)));
byte[] c3 = Hex.Decode(Encoding.Default.GetBytes(data.Substring(130 + 2 * c2Len 64)));
SM2 sm2 = SM2.Instance;
BigInteger userD = new BigInteger(1 privateKey);
ECPoint c1 = sm2.ecc_curve.DecodePoint(c1Bytes);
Cipher cipher = new Cipher();
cipher.Init_dec(userD c1);
cipher.Decrypt(c2);
cipher.Dofinal(c3);
return c2;
}
///
/// 获取生成的公钥私钥
///
/// out prik 私钥
/// out pubk 公钥
///
public void GenerateKeyPair(out string prik out string pu
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
I.A.... 3 2019-11-30 14:02 ChinaEncrypt\.svn\entries
I.A.... 3 2019-11-30 14:02 ChinaEncrypt\.svn\format
I.A...R 20992 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\02\0227ba5487fda386d61f0a07f9eed2027ebf788a.svn-ba
I.A...R 1332 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\02\0253ba78d96223e08664ae7b6895ecfb3dd13543.svn-ba
I.A...R 60928 2019-12-05 11:43 ChinaEncrypt\.svn\pristine\02\02e321364e850d167bce9096433efe7fe91ae7a8.svn-ba
I.A...R 9255 2019-12-05 11:43 ChinaEncrypt\.svn\pristine\0e\0e228f623cc31293b515171a5d5c5d657a1095d3.svn-ba
I.A...R 56832 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\16\16c1c52e04746f99b59f1363690e7374bcff2470.svn-ba
I.A...R 45056 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\1d\1daf310b4cbb687af669f54653144c177de47031.svn-ba
I.A...R 25088 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\28\28ddcd2c458b09067788fe020c0bc111fb0d54fd.svn-ba
I.A...R 652 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\2b\2bd139bddaa1e5018819fcab1c43ddf896844cbe.svn-ba
I.A...R 2843 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\32\32492efe987c732f7c7ef04f36eb7c604f0ffc17.svn-ba
I.A...R 69632 2019-12-05 11:43 ChinaEncrypt\.svn\pristine\3b\3b42a7d9ee62418fc53a4b95ca1490a690b60fb4.svn-ba
I.A...R 22016 2019-12-05 11:43 ChinaEncrypt\.svn\pristine\3c\3ceffc0fbc4c22336821d90b10e6229ba764bfd1.svn-ba
I.A...R 6730 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\3d\3dfee66dd0fd9dbeddd8df82052b188c9641c4bc.svn-ba
I.A...R 2934 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\48\48ed232c4531cfe23d3e0d837edd9a7e0b26ae48.svn-ba
I.A...R 815 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\4f\4f664066b8275d6a48e9296abc38b2d6d817d804.svn-ba
I.A...R 20480 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\5c\5cd5669f917413cc48ba50f35d798a3b1c79e2dc.svn-ba
I.A...R 7015 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\69\69f38c2381b0f8a497537d834ddbd473727e2e04.svn-ba
I.A...R 6745 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\6c\6c174f142f6f74c24908f91374e698cb2bfdf9ae.svn-ba
I.A...R 1212416 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\72\72064d6a14a346bddaff021783aeb43835d10ebc.svn-ba
I.A...R 12519 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\78\782b12e77576f9d7af8423a2e41113419d41c8fc.svn-ba
I.A...R 7069 2019-12-05 11:43 ChinaEncrypt\.svn\pristine\7d\7dc054544632e2255c0d6afcf39ff1ff2f4243fd.svn-ba
I.A...R 435 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\87\87ad2be0e055247437c5e803b69cb7b13f83a2fb.svn-ba
I.A...R 2242 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\8a\8a2c827a018204aefaca3cc447492dd1715dd95d.svn-ba
I.A...R 42496 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\a6\a6d32a700de3ef988a822396dcde02265cae54e1.svn-ba
I.A...R 6904 2019-12-05 11:43 ChinaEncrypt\.svn\pristine\ab\abd678a8a806910c3a71c431ded4eea4e5d72f52.svn-ba
I.A...R 5709 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\b2\b24df188d855088a98412237a9712d947c9aeb06.svn-ba
I.A...R 1504 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\b6\b66a0a430e6e759d327b8483c041911e60f1e029.svn-ba
I.A...R 62976 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\b7\b74fde4b2b45e1f43b92783a230ac8a40821e00c.svn-ba
I.A...R 962 2019-11-30 14:02 ChinaEncrypt\.svn\pristine\b7\b7a846d06f73f32d4a441bc47ad2cf609d1849f1.svn-ba
............此处省略115个文件信息
相关资源
- HorizontalScrollViewfragment自动翻页功能(
- Tetris.zip
- NeuralNetworksDeepLearning_jb51.rar
- CMOS模拟集成电路设计与仿真(罗广孝
- jmxzl6.ppt
- jake_cai_9738404.zip
- Ansys192.Crack.zip
- 一健破解Studio5000Logix.rar
- modbus_poll和modbus_slave_64bit.rar
- dewi.rar
- 图像与视频压缩技术讲义.rar
- teamviewer.quicksupport.addon.samsung.rar
- invadersf_10261826.zip
- innersense_3120291.zip
- 中国商用密码.rar
- 垃圾短信拦截系统的设计与实现.kdh
- BASIS学习环境服务器搭建方案.pdf
- 1068515楼月免费MP3录音软件v3.0.zip
- 串口工具.zip
- 亿景简单进销存2017服装版Reg注册版
- 宏达服装租赁管理系统Reg注册版.rar
- 宏达电梯维修管理系统专业版Reg注册
- EPM公式.rar
-
Jsc
ript.NET程序开发.pdf - 07SD101-8_电力电缆井设计与安装.pdf
- huaqianshu1_10760544.zip
- SetupNetwork.rar
- 金融行业标准(JRT0123—2018)《非银行
- XunFeiVoiceWebAPI.zip
- 自编Sniffer含源代码.rar
评论
共有 条评论