Exemple #1
0
func decrypt(key *rsa.PrivateKey, ciphertext string) (string, error) {
	cipherBytes, err := base64.StdEncoding.DecodeString(ciphertext)
	if err != nil {
		panic(err)
	}
	decrypted, err := key.Decrypt(rand.Reader, cipherBytes, crypto.SHA1.New())
	if err != nil {
		return "", err
	}
	return base64.StdEncoding.EncodeToString(decrypted), nil
}