Example #1
0
/*
介绍:根据指定的key,和padding来创建RSACipher

作者:Alex
版本:release-1.1
*/
func NewRSAWith(key rsa.Key, padding rsa.Padding, cipherMode rsa.CipherMode, signMode rsa.SignMode) (rsa.Cipher, error) {
	return rsa.NewCipher(key, padding, cipherMode, signMode), nil
}
Example #2
0
/*
介绍:创建RSACipher,默认使用pkcs1 padding,pkcs#1v1.5 加密解密,pkcs#1v1.5签名验证.

作者:Alex
版本:release-1.1
*/
func NewRSA(key rsa.Key) (rsa.Cipher, error) {
	padding := rsa.NewPKCS1Padding(key.Modulus())
	cipherMode := rsa.NewPKCS1v15Cipher()
	signMode := rsa.NewPKCS1v15Sign()
	return rsa.NewCipher(key, padding, cipherMode, signMode), nil
}