how can i create RS256Algorithm instance?
li-zheng-hao opened this issue · 2 comments
li-zheng-hao commented
i create my private key and public key by PuTTY Key Generator tool, the test private key and public key are as follows:
PuTTY-User-Key-File-3: ssh-rsa
Encryption: none
Comment: rsa-key-20220722
Public-Lines: 6
AAAAB3NzaC1yc2EAAAADAQABAAABAQCLm8nRtjHsN87EuJgmkADhHshz29I6FeU+
H43AfLd25dL3OjTxLhpG+3jWsoL6eXRRZEZY40m0fYJoC56ZldJQKWaJ00/UX6v0
O0T13aVq0BjSa2IE/WrWidXi+CgOtfTmUjS8YdqpZCK8yX8fiBnw2yCZJZf/kDhM
SBHgTG7kvSyfyREK7MgQ0ncDnHNeYBbNdD2tZ8Sce79Hiv5mNSGeVDUDEkysr/dZ
bB/9E4uAmN4MDRc923KR+0N1h7gZymLEsPhkxkJjIL8DCbvsTV9m/cTYM4FK2upV
Kk5N/rDzcgUQnSHN25qPZg54UhfidJ/DQ0e+83C72wdkUol4zwoD
Private-Lines: 14
AAABAHUYHZY/cm/l/w8QpMzzS0mGQCqs3Q7K/pO0c3hXIqoe6Wti7rS7Ll8K3Ld2
0lSzOdRqfnZfbJpuCsqptEStXNDPaKmBCxvdgqQ+cgCl/vAvyiHy3yvAQbPft/2+
lhqAkv/7QzAeAwDAdEJT3sPbq6ZQpG7PEUXQ+OdCK3wtn3VJ0Tp4MOpN+UM0l2I3
Q7FkohtV6/NuKuIb2SSo0vUjD1aBIQvs6bKSDff4HLiwkK3vl8r5moArl6xQVQh5
9q1meGTJioKaxIrbK6HxwhoE+vE6/bvmfBJNNuRlFDllwWyjJyPqi/ig3XQppsnM
4zkFCbgMMhbcQsxfV9W2iEfYOcEAAACBAOtN8R79UcdHVaN2+PhsPoNcV4CahlRc
GwnPjx23Eva3zmiL2esh3RMpwKTxYGWDVYWnjdjJdwmCfgqF2h8TXEVwpjz64bYM
x01Ots1RwLKkqJlWz/y9goKx4iS2yj8Dn8nJSIMQ9m86o/bYyn0shgftPbiack47
juucg8vzLva9AAAAgQCX4y44KUGRMZi4d+RkvKoStyhBLzlgFIftKsasywyJfcnC
a3TJkbL1bWDLLxuJ/zL/5Ivi3brGd4N5uWXXu721QFxUmXJbNHuw+2Me1dTSEBAG
Gn/olhhQwP7MalZDISqzqehPvGzyTYjGkiMPCj7ooAHcU7fSZLdkX3SVz/1vvwAA
AIEAzVn4HW2yB4+uq4/4yI4mz/A2VnvOVuRcubqMQbzCjOfVWCOqMIR6hKg8F+6d
sFat/7LyDGDVY+CJwFzGnOoTmWE+d/spo9+YL9dX5K3LLSfdFATok6NFYB0vUfvR
UXYkct5V9gr4E9FMZaTvfHVVLp+mJ1WaNFuomNG+XsMqUAc=
Private-MAC: 2c71fa5fde185cd9a98f344421dff0d93be8cc427181abd5c1feb89695377a18
and how can i use this string to create RS256Algorithm
instance?
var publicKey=?
var privateKey=?
IJwtAlgorithm algorithm = new RS256Algorithm(publicKey,privateKey); // how to pass two parameters?
abatishchev commented
Hi, you here to figure out (e.g. search on Stack Overflow) how to create an X509Certificate2
object from the given base64 string. And then pass it to the ctor .
li-zheng-hao commented
thx @abatishchev , i solve it by this way:
var rs=RSA.Create(2048);
// export string and then save in config file
//privExport= Convert.ToBase64String(rs.ExportRSAPrivateKey());
//pubExport= Convert.ToBase64String(rs.ExportRSAPublicKey());
// import public or private key
rs.ImportRSAPublicKey(Convert.FromBase64String(pubExport), out _);
rs.ImportRSAPrivateKey(Convert.FromBase64String(privExport),out _);
it works well