golang-module/dongle

Recently encountered coding BCD and RSA no padding

alonelucky opened this issue · 0 comments

Feature Request

  1. Encrypted and encoded as BCD Binary-coded decimal
  2. rsa no padding (unsafe)
// rsa no padding encrypt
func LowerSafeEncrypt(pub *rsa.PublicKey, msg []byte) []byte {
         m := new(big.Int).SetBytes(msg)
	e := big.NewInt(int64(pub.E))
	return new(big.Int).Exp(m, e, pub.N).Bytes()
}

// rsa no padding decrypt
func LowerSafeDecrypt(priv *rsa.PrivateKey, msg []byte) []byte {
        c := new(big.Int).SetBytes(msg)
	return new(big.Int).Exp(c, priv.D, priv.N).Bytes()
}