加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

C#使用椭圆签名算法制作软件序列号

发布时间:2020-12-15 17:59:13 所属栏目:百科 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 ? ? 椭圆曲线密码学(Elliptic curve cryptography,缩写为ECC)是基于椭圆曲线数学的一种公钥密码的方法。椭圆曲线在密码学中的使用是在1985年由Neal

以下代码由PHP站长网 52php.cn收集自互联网

现在PHP站长网小编把它分享给大家,仅供参考

? ? 椭圆曲线密码学(Elliptic curve cryptography,缩写为ECC)是基于椭圆曲线数学的一种公钥密码的方法。椭圆曲线在密码学中的使用是在1985年由Neal Koblitz和Victor Miller分别独立提出的。

// 生成R=r*G  
TBCryptoBigInteger r = null;  
Random random = new SecureRandom();  
do // Generate r  
{  
    r = new TBCryptoBigInteger(this.ecdomainpsCDKey.N.BitLength,random);  
}  
while (r.SignValue == 0);  
ECPoint R = this.ecdomainpsCDKey.G.Multiply(r);  
// Hash = SHA1(data,Rx,Ry)  
string hashStr = Sha1(31,rawKeyBytes,R.X.ToBigInteger().ToByteArray(),R.Y.ToBigInteger().ToByteArray());  
TBCryptoBigInteger hashInt = new TBCryptoBigInteger(hashStr,2);  
// sig = r-Hash*D (mod n)  
TBCryptoBigInteger sig = r.Subtract(hashInt.Multiply(this.ecDCDKey)).Mod(this.ecdomainpsCDKey.N); 

    // 验证签名  
    X9ECParameters ecps = X962NamedCurves.GetByOid(X9ObjectIdentifiers.Prime256v1);  
    ECPublicKeyParameters pk = new ECPublicKeyParameters("ECDSA",ecps.Curve.DecodePoint(Hex.Decode(KeyAttribute.GetKey(type.Assembly))),new ECDomainParameters(ecps.Curve,ecps.G,ecps.N,ecps.H));  
    ISigner s = SignerUtilities.GetSigner("ECDSA");  
    s.Init(false,pk);  
    s.BlockUpdate(bytes,dataLen);  
    if (s.VerifySignature(sig))  
    {  
        this.data = new byte[dataLen];  
        Array.Copy(bytes,this.data,data.Length);  
    }  

以上内容由PHP站长网【52php.cn】收集整理供大家参考研究

如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读