golang-module / dongle

A simple, semantic and developer-friendly golang package for encoding&decoding and encryption&decryption
https://pkg.go.dev/github.com/golang-module/dongle
MIT License
875 stars 67 forks source link

Recently encountered coding BCD and RSA no padding #22

Open alonelucky opened 7 months ago

alonelucky commented 7 months ago

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()
}