1 Star 0 Fork 0

李易 / gorm-dm8-dialect

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
zzb.go 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
zhenyong.li 提交于 2024-01-19 02:47 . update driver to embed dm8
/*
* Copyright (c) 2000-2018, 达梦数据库有限公司.
* All rights reserved.
*/
package security
import "math/big"
type DhKey struct {
x *big.Int
y *big.Int
group *dhGroup
}
func newPublicKey(s []byte) *DhKey {
key := new(DhKey)
key.y = new(big.Int).SetBytes(s)
return key
}
func (dk *DhKey) GetX() *big.Int {
x := new(big.Int)
x.Set(dk.x)
return x
}
func (dk *DhKey) GetY() *big.Int {
y := new(big.Int)
y.Set(dk.y)
return y
}
func (dk *DhKey) GetYBytes() []byte {
if dk.y == nil {
return nil
}
if dk.group != nil {
blen := (dk.group.p.BitLen() + 7) / 8
ret := make([]byte, blen)
copyWithLeftPad(ret, dk.y.Bytes())
return ret
}
return dk.y.Bytes()
}
func (dk *DhKey) GetYString() string {
if dk.y == nil {
return ""
}
return dk.y.String()
}
func (dk *DhKey) IsPrivateKey() bool {
return dk.x != nil
}
func copyWithLeftPad(dest, src []byte) {
numPaddingBytes := len(dest) - len(src)
for i := 0; i < numPaddingBytes; i++ {
dest[i] = 0
}
copy(dest[:numPaddingBytes], src)
}
Go
1
https://gitee.com/java-dev101/gorm-dm8-dialect.git
git@gitee.com:java-dev101/gorm-dm8-dialect.git
java-dev101
gorm-dm8-dialect
gorm-dm8-dialect
v0.9.2

搜索帮助