keysize 2048

public key(Hex)

85da3d445b203823daa4727eb5701d9c405ed6b1b658d098fb5e8cbbbe2d10b6

d885fc4bbee105d7e5c0d6c970fff5973c647ee8a201239f379796b628203ac7

2d9d05d18a5796a30ad4b8fbde73cc398057ad856c971567e5d5f8fe47785518

417e0947ec9df8a63c517bbc3783cede111fc5467ee8df1a5b8e74abd5cf46da

876ca61f74b5bb998dc7021eb397fc55585137f74763d249ce256fc92437a894

230071a70d95d737928231120b665a0ca3e48124c9a001525070cf6f0bf79346

1d506ce67f7527c24aa3b70c8bd327eae19abebe27393e3927ac0d06789e129d

ae52e455084eec63a4bc35470ecf71a65c2ff78a3596841f3ed998d4acc6d1ed


private key(Hex)

726503fb898dcdad06cd8874b607eda67e750f33ae4dd569095bd31718ff56cb

8ddd64b42f9c0cec691517fbed3133e95ed9dc8461006c3b44bdaf365ab0c0cb

3d3677a48f812fe283fd2d6344c8de7f3e2ab0c7d8f87e78df3ab1a44fdc8d8d

3f5bc1fed0406a235865a3444685c5a4902a00e5b0ccc0efbbd3d1ee91baa628

1c32c85dd43f04e10cba4202c5726c5566dd2f3204b2db219eaf311ef9659ca0

eff04b9ce37cf2dff3fd067b3291d117c7bfb2e00e4aad17c97353b280326ab9

0dd97bd07a3f022b87c835dc299cb81d297c2ea3b6bd345833d1ab5915d242bd

70224e4a3c0804d05e374e1ad81a10d87e78169189a5a948ee2c2a89e119bb59


Text

123


Encrypted result(Hex)

051d820df327c86feb60f6ab9b4e7c72f60f71fea88c4a80ae797ec95c1eb199

6ca31c57253f0b14c236ca6d82ff1e1d4f7682c3c9bc49ce242c7986186d6acb

41d68bfe473e1edc168b7a882c1b2934aaa01c03a69d0cdf649b945b275a6e2e

f25c1f9516d3a99d26dbb7cf558db0455738da2bac83a1f39e6ec0d3ad717e7f

418fe8c07de06e910a775ed55d69d83df81ea6cd06c9c1e20bdfd7bbd22cae47

cad0d7e37cf79b6394592be3991635e7b60cc50e35b4265c3d93def720906666

5992f608eba1c4f2a8c1ed430eb17d8cc057486bc3a270264259a25d029c3e93

9ee260e93d6618beab18ed14e7b96ded3e5fdc515e9a6002b7e20f457c1ece1f


Decrypted result

123


I took a look at what that site is doing and it appears that the "public key" in the public key textbox is just the modulus from the RSA key (​​n​​​), hex encoded. An RSAPublicKey consists of the modulus (​​n​​​) and the public exponent (​​e​​) in an ASN.1 sequence.

RSAPublicKey ::= SEQUENCE {
modulus INTEGER, - n
publicExponent INTEGER - e
}

Having just the ​​n​​​ value from that site isn't enough. Anecdotally, the site appears to use a hard coded ​​e​​ of 0x10001, which is actually fine.


If you need to generate an RSA key, I would recommend using something that can export to a standardized key format. Using .NET for example:

using System.Security.Cryptography;

using RSA rsa = RSA.Create(2048);
byte[] pkcs1PublicKey = rsa.ExportRSAPublicKey();


用这里的代码,导出一个字节数组,并且打印Hex

pkcs1PublicKey.Length = 270

3082010a0282010100d095bcfebef1361f3daa081254d017ddd3f7a3cb0fc71a9cf3bac8ccc1f72121ee26993388c1b44663bd083f1e8944b06a559e65ff777ef8d84c1fd4388318cfc74856afd63f116f999bc461e3e06d921f315ef40225f7077524faeaf1a7d10887e89f0b76f2ad95a87089d274d9b400a80e72bb4dfcad42380f02e746807ecebefb370392b78c7b125ea26fc27b50f9c470cf5d7b39f684b6d7318accbd9b5e36747f9ee54f8ab226444ba5728e34fef4ea06b3ed9cb6c65f8495314ca9442ea089db655de70e6a665fc5057be76d26b82cb2a16c8dc72ccf39cfacd926d732242496f480606d6626f3a4300a8ec583b43b4127a81544e2be19dde0c2d19f6d0203010001

pkcs1PrivateKey.Length = 1192

308204a40201000282010100d095bcfebef1361f3daa081254d017ddd3f7a3cb0fc71a9cf3bac8ccc1f72121ee26993388c1b44663bd083f1e8944b06a559e65ff777ef8d84c1fd4388318cfc74856afd63f116f999bc461e3e06d921f315ef40225f7077524faeaf1a7d10887e89f0b76f2ad95a87089d274d9b400a80e72bb4dfcad42380f02e746807ecebefb370392b78c7b125ea26fc27b50f9c470cf5d7b39f684b6d7318accbd9b5e36747f9ee54f8ab226444ba5728e34fef4ea06b3ed9cb6c65f8495314ca9442ea089db655de70e6a665fc5057be76d26b82cb2a16c8dc72ccf39cfacd926d732242496f480606d6626f3a4300a8ec583b43b4127a81544e2be19dde0c2d19f6d0203010001028201010089c36c4940a9a5da6a6ae3dbdfa27530f0efed818f912c559f70ad70f76716be0741fd0b99767e6fc32e35c52290fd0a1ba122f6310da6920aa1f49fc1176d0ac68f5399dd42586cc222ac490f2dca90a9037db861b6db7a5477b135fd979e2b29408dd30fa3e6dc229cf99a43cd09e3291c29d0e6084e129f5de2c807bb94841d1dbf4ef8b6fb7b9cd175a067f3ce5192e50d9974b86c0ba4f8b1974452f1e357d1403cb17f8688edbb726223a3b330337e525976361bdf34116b5632eb491d4c938ba821d00a3029a7272f10630a3fb336bf9fa92dd26c5731bc9281c0ac8677883a0fcde28d510ccebd3c423514585dc1742858b9d2a2e653ffb54088c90d02818100eeac9b9c7f81224c4b83c7c234de144fab5743340c5b7f3685228552ba159ba98456669b7104801c1cf74ff36944a0574e552f7a0ce2a196461fca9f9c8423ac4129bd9c8fb51b82071a84d5d4b6e2f9f6d3b61513b35ac04b9ad99eb8b297d18291c45ae1140aedf8cda3298686842310e91fb5f332953eeb3ba5deb056a4bf02818100dfb9f7744c9c6ad7735537dd41211e3bb1db33ba77a0f87c25e9210fdcb470f67867054419590a4fb3b7fee2bd853a30c4fbd23ddad6bb28a2be54cb50bd1fbfb0152fd4af3a14bc7a2c38f09a77a4bb44e70361fa70c8ec228b18b014ed132952042da67f7bba32ce0f6c497986c6c891b589dcb3e28dc843087b69693faad30281807af39e623b68e9a3460f87fb6ac2b0d1ede1513461dd4ca66865452b3dc35de230d3559e63d53eadbcda466c8d6115fc83d4ec5542880957e19e0502be5d70070fb692003223c91cedcde27a494f4194256c20d3b0c7674bc266ee0e8ef529b27b41de5636b6dd7e83fa63404415cdc246b6e16818f588ded5cd6f804d7504ff0281800b1f3998047efa28bfc90abfeb0ef46bcf49b066a2afd3ea880ff0ded2fffd65a352abc658e43e48fc0c37959a0a577c392eb3a2f3901d39c5ed6455bf2bc7ba45cca7d610e7f843ee66e865bda818fe5e4c85b48738b824550b492ce7bd6968727556b7a23aca64e02d901a8efa0e43c64a9a11e8b76888fe1c1bd67faef49502818100a37367039cdcd5dd8446219fc911142bb33c8c9249098a6ac9f51885f1723042a2c83447b6e98da095c09c765edf39b3d0d2d778ee3f29b3a66d7572145a9e73e026b31f7ac33335da990c1f2dd0a4e1393026bf9f35a3fe75c68a70127b5db0074e026b21886ff96aea2835d07051facadfb11eb2e86ccad9115dc2a9988953

RSAPrivateKey ::= SEQUENCE {
version Version,
modulus INTEGER, -- n
publicExponent INTEGER, -- e
privateExponent INTEGER, -- d
prime1 INTEGER, -- p
prime2 INTEGER, -- q
exponent1 INTEGER, -- d mod (p-1)
exponent2 INTEGER, -- d mod (q-1)
coefficient INTEGER, -- (inverse of q) mod p
otherPrimeInfos OtherPrimeInfos OPTIONAL
}


公钥

270

parameters.D.Length =

parameters.D =

parameters.DP.Length =

parameters.DP =

parameters.DQ.Length =

parameters.DQ =

parameters.Exponent.Length = 3

parameters.Exponent = 010001

parameters.InverseQ.Length =

parameters.InverseQ =

parameters.Modulus.Length = 256

parameters.Modulus = d095bcfebef1361f3daa081254d017ddd3f7a3cb0fc71a9cf3bac8ccc1f72121ee26993388c1b44663bd083f1e8944b06a559e65ff777ef8d84c1fd4388318cfc74856afd63f116f999bc461e3e06d921f315ef40225f7077524faeaf1a7d10887e89f0b76f2ad95a87089d274d9b400a80e72bb4dfcad42380f02e746807ecebefb370392b78c7b125ea26fc27b50f9c470cf5d7b39f684b6d7318accbd9b5e36747f9ee54f8ab226444ba5728e34fef4ea06b3ed9cb6c65f8495314ca9442ea089db655de70e6a665fc5057be76d26b82cb2a16c8dc72ccf39cfacd926d732242496f480606d6626f3a4300a8ec583b43b4127a81544e2be19dde0c2d19f6d

parameters.P.Length =

parameters.P =

parameters.Q.Length =

parameters.Q =


私钥

1192

parameters.Modulus.Length = 256

parameters.Modulus = d095bcfebef1361f3daa081254d017ddd3f7a3cb0fc71a9cf3bac8ccc1f72121ee26993388c1b44663bd083f1e8944b06a559e65ff777ef8d84c1fd4388318cfc74856afd63f116f999bc461e3e06d921f315ef40225f7077524faeaf1a7d10887e89f0b76f2ad95a87089d274d9b400a80e72bb4dfcad42380f02e746807ecebefb370392b78c7b125ea26fc27b50f9c470cf5d7b39f684b6d7318accbd9b5e36747f9ee54f8ab226444ba5728e34fef4ea06b3ed9cb6c65f8495314ca9442ea089db655de70e6a665fc5057be76d26b82cb2a16c8dc72ccf39cfacd926d732242496f480606d6626f3a4300a8ec583b43b4127a81544e2be19dde0c2d19f6d

parameters.Exponent.Length = 3

parameters.Exponent = 010001

parameters.D.Length = 256

parameters.D = 89c36c4940a9a5da6a6ae3dbdfa27530f0efed818f912c559f70ad70f76716be0741fd0b99767e6fc32e35c52290fd0a1ba122f6310da6920aa1f49fc1176d0ac68f5399dd42586cc222ac490f2dca90a9037db861b6db7a5477b135fd979e2b29408dd30fa3e6dc229cf99a43cd09e3291c29d0e6084e129f5de2c807bb94841d1dbf4ef8b6fb7b9cd175a067f3ce5192e50d9974b86c0ba4f8b1974452f1e357d1403cb17f8688edbb726223a3b330337e525976361bdf34116b5632eb491d4c938ba821d00a3029a7272f10630a3fb336bf9fa92dd26c5731bc9281c0ac8677883a0fcde28d510ccebd3c423514585dc1742858b9d2a2e653ffb54088c90d

parameters.P.Length = 128

parameters.P = eeac9b9c7f81224c4b83c7c234de144fab5743340c5b7f3685228552ba159ba98456669b7104801c1cf74ff36944a0574e552f7a0ce2a196461fca9f9c8423ac4129bd9c8fb51b82071a84d5d4b6e2f9f6d3b61513b35ac04b9ad99eb8b297d18291c45ae1140aedf8cda3298686842310e91fb5f332953eeb3ba5deb056a4bf

parameters.Q.Length = 128

parameters.Q = dfb9f7744c9c6ad7735537dd41211e3bb1db33ba77a0f87c25e9210fdcb470f67867054419590a4fb3b7fee2bd853a30c4fbd23ddad6bb28a2be54cb50bd1fbfb0152fd4af3a14bc7a2c38f09a77a4bb44e70361fa70c8ec228b18b014ed132952042da67f7bba32ce0f6c497986c6c891b589dcb3e28dc843087b69693faad3

parameters.DP.Length = 128

parameters.DP = 7af39e623b68e9a3460f87fb6ac2b0d1ede1513461dd4ca66865452b3dc35de230d3559e63d53eadbcda466c8d6115fc83d4ec5542880957e19e0502be5d70070fb692003223c91cedcde27a494f4194256c20d3b0c7674bc266ee0e8ef529b27b41de5636b6dd7e83fa63404415cdc246b6e16818f588ded5cd6f804d7504ff

parameters.DQ.Length = 128

parameters.DQ = 0b1f3998047efa28bfc90abfeb0ef46bcf49b066a2afd3ea880ff0ded2fffd65a352abc658e43e48fc0c37959a0a577c392eb3a2f3901d39c5ed6455bf2bc7ba45cca7d610e7f843ee66e865bda818fe5e4c85b48738b824550b492ce7bd6968727556b7a23aca64e02d901a8efa0e43c64a9a11e8b76888fe1c1bd67faef495

parameters.InverseQ.Length = 128

parameters.InverseQ = a37367039cdcd5dd8446219fc911142bb33c8c9249098a6ac9f51885f1723042a2c83447b6e98da095c09c765edf39b3d0d2d778ee3f29b3a66d7572145a9e73e026b31f7ac33335da990c1f2dd0a4e1393026bf9f35a3fe75c68a70127b5db0074e026b21886ff96aea2835d07051facadfb11eb2e86ccad9115dc2a9988953


PKCS#8格式的密钥

-----BEGIN PUBLIC KEY-----

MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyruP7ENvJdXtAQW9LU3q

vuBHNu5mbXnNLcMyDP2mb91IwSsCa3tW3+kDxoIBlaNYIdBBt/oS0CBZoxM0wNd2

za0ZCe+NTeGyRAkpFESHee02lO+dhRq/v6G08njjDqxL7Mbz/QERyy9YEy61iLzx

0vfHmLoAL6hRPTBt0PhhvNjS3AJBsKX0vC+xh/oQg8bEdcL0chCwu+XsAdkD2WMU

qpfHdCvmfZmn3UuTzis+ZctOWJd8nJsONACu2o/meiaJlzBP+G3RIrmH0uFnUzvE

eHVdCAy8/lsEA6tstTNynfqeizQng7CaNaMhubOGXCOkXWyzwYnT3zv3Q7ter+pQ

PQIDAQAB

-----END PUBLIC KEY-----


-----BEGIN PRIVATE KEY-----

MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDKu4/sQ28l1e0B

Bb0tTeq+4Ec27mZtec0twzIM/aZv3UjBKwJre1bf6QPGggGVo1gh0EG3+hLQIFmj

EzTA13bNrRkJ741N4bJECSkURId57TaU752FGr+/obTyeOMOrEvsxvP9ARHLL1gT

LrWIvPHS98eYugAvqFE9MG3Q+GG82NLcAkGwpfS8L7GH+hCDxsR1wvRyELC75ewB

2QPZYxSql8d0K+Z9mafdS5POKz5ly05Yl3ycmw40AK7aj+Z6JomXME/4bdEiuYfS

4WdTO8R4dV0IDLz+WwQDq2y1M3Kd+p6LNCeDsJo1oyG5s4ZcI6RdbLPBidPfO/dD

u16v6lA9AgMBAAECggEAQmAQaglWDawx0aDgZEHbdq0Vg92f+X3keHQtIeW2JW/s

zxnWy/vw4JR44PhVrnlxdHir26FroWrGDkdOgUjKI+LljMQ6nmIjrHTXV0RsmrXY

pgChsR+l4gb+qFh99qLgpOAqqA4+liilDHrBgshh4HGxjsZvIytXldISUlXQIjTB

km1jMDsF7TfVlgFy+R6QhKVnNRYwbles3bARq1pz5nsleRnI2ykmXh0h5MFMhbKI

UaiqPAgWKu3iNfhOdbrCZKF2uxgEMzFZyP9kwxKu/4RMrLgu4xgh54sFFr27f6sx

pQf/kGzI8f/PlDwqwkOYLlC/AdnWFxQAzpw0b7czPQKBgQD1sfwDd/9Rm9I9sanC

Tf6QrldboHo/C8t8xH8MAsMtnckoYzPPlRlNksQDkZBn6bPTx7O5oRAO7zaOKmp6

rWxJWDw68518QmToGFiXKwYxSBUEri821FOodJ43rX2peQ1p1/+gJ/F2JrDQlGDx

nIrGGfYriUgrAx2bNIjWxsHxfwKBgQDTPEp99dwMuTCkgUUvrBsN6HIf9yQnBLQc

+OGR3EdD66OKJgkv2CTlgknPL2gzNhS162vMYDMZq+UvZonlwZ4Idu9FCKWIOWAy

dj18Eyt+F8V7BZZrxRTpPcqjML4NCbEwpA6qQ1Hu9/6ZTY5wKdAsnUqKDMtXmZRG

APzUY23kQwKBgQDq+hwB3UPL8vCxnDa05A7wpCxcLzB7F3a3jt3KyOGNwPffrnCg

uQIIFLNujkrDdtlLVBTpFcbb4aAVey92wGFuC/sejlsxufXzm0Uu3jD/9OZVIZl6

ILsZwt6GdWBXMrTHY5LQwyLFUt+LvDyzFnoKWE38+UCSElrAUxAECPb3VQKBgHeR

tDTyu5m0JjWoOuqOSE4qGpe/hIZVokKYGs8+2lQ3CT6E40Ri3BfSFUei9R+v6C9F

0KJCfgp1A+k96KbWX0c5U51HFLQ0jiBiT9Fw5HieqhlGA2yDhZ+1a4PObnXg25zF

8MsuCi3z0PkkLpGNCZqHeo8ESQIQHB84JeVvVuATAoGAFbbLkj7g1XiNbEBEcVyz

Tw8tFaWlvzsy04F6oKe9M19CnhJ2XUydcD+58qb9C8WTPz84Auz0D6ikr4c1CpL/

pK7B12Vs1UesXr3ZmtUKYeAQSZv/nwY9FRifV4jMrNZCmISHuHhWBJR7O5y///vo

vBWYNNw3eer3ZwJGeQ4XopY=

-----END PRIVATE KEY-----


​​密钥格式​​

 Key data may be encoded in three general ways:

Binary DER-encoded format

This is sometimes called ASN.1 BER-encoded (there is a subtle difference between BER- and DER-encodings: DER is just a stricter subset of BER, but consider them the same here). The most compact form. If you try to view the file with a text editor it is full of "funny" characters. The first byte in the file should be a '0' character (U+0030).

PEM or base64 format

This is the same data as the DER-encoded file but it is encoded in base64 with additional header and footer lines:

-----BEGIN FOO BAR KEY-----
MIIBgjAcBgoqhkiG9w0BDAEDMA4ECKZesfWLQOiDAgID6ASCAWBu7izm8N4V
2puRO/Mdt+Y8ceywxiC0cE57nrbmvaTSvBwTg9b/xyd8YC6QK7lrhC9Njgp/
...
-----END FOO BAR KEY-----

These files can be viewed with a text editor and can be easily transmitted as part of an email message. The first character in the base64-encoded part should be a 'M' (U+004D).

XML format

There are W3C standards for this, and, er, a .NET way that predates the latest W3C standard. Here is an example of the W3C [XKMS] 2.0 format

<RSAKeyPair>
<Modulus>4IlzOY3Y9fXoh3Y5f06wBbtTg94Pt6vcfcd1KQ0FLm0S36aGJtTSb6pYKfyX7PqCUQ8wgL6xUJ5GRPEsu9
gyz8ZobwfZsGCsvu40CWoT9fcFBZPfXro1Vtlh/xl/yYHm+Gzqh0Bw76xtLHSfLfpVOrmZdwKmSFKMTvNXOFd0V18=
</Modulus>
<Exponent>AQAB</Exponent>
<P>9tbgIiFMXwpw/yf85bNQap3lD7WFlsZA+qgKtJubDFXCAR35N4KKFMjykw6SzaVmIbk80ga/tFUxydytypgt0Q==</P>
<Q>6N6wESUJ0gJRAd6K6JhQ9Xd3YaRFk2sIVZZzXfTIWxKTInOLf9Nwf/Wkqrt0/Twiato4kSqGW2wU6K5MnvqOLw==</Q>
<DP>l0zwh5sXf+4bgxsUtgtqkF+GJ1Hht6B/9eSI41m5+R6b0yl3OCJI1yKxJZi6PVlTt/oeILLIURYjdZNR56vN8Q==</DP>
<DQ>LPAkW/qgzYUi6tBuT/pszSHTyOTxhERIZHPXKY9+RozsFd7kUbOU5yyZLVVleyTqo2IfPmxNZ0ERO+G+6YMCgw==</DQ>
<InverseQ>
WIjZoVA4hGqrA7y730v0nG+4tCol+/bkBS9u4oiJIW9LJZ7Qq1CTyr9AcewhJcV/+wLpIZa4M83ixpXub41fKA==
</InverseQ>
<D>pAPDJ0d2NDRspoa1eUkBSy6K0shissfXSAlqi5H3NvJ11ujNFZBgJzFHNWRNlc1nY860n1asLzduHO4Ovygt9DmQb
zTYbghb1WVq2EHzE9ctOV7+M8v/KeQDCz0Foo+38Y6idjeweVfTLyvehwYifQRmXskbr4saw+yRRKt/IQ==
</D>
</RSAKeyPair>

The white space in the content or between the tags should not matter, at least as far as our functions are concerned. The .NET version uses ​​<RsaKeyValue>​​ instead, which is strictly only for a public key.