dongle icon indicating copy to clipboard operation
dongle copied to clipboard

Recently encountered coding BCD and RSA no padding

Open alonelucky opened this issue 1 year ago • 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()
}

alonelucky avatar Jan 31 '24 02:01 alonelucky