_, serverPublicKey := generateRsaPair(2048)ĬlientPrivateKeyAsByte := privateKeyToBytes(clientPrivateKey)ĮncryptWithPublicKey(clientPrivateKeyAsByte, serverPublicKey)įatal error crypto/rsa: message too long for RSA public key size /* Functions */įunc generateRsaPair(bits int) (*rsa.PrivateKey, *rsa. Similarly, encryption and verification both use the. * main */ĬlientPrivateKey, _ := generateRsaPair(2048) Decryption and signing are identical as far as the mathematics is concerned as both use the private key. Your method of saving the private key throws away the newlines which loadpemprivatekey () expects to see. It is an asymmetric cryptographic algorithm which means that there are two different keys i.e., the public key and the private key. but I saw a similar task was done in Python, so I want to know your opinion. This algorithm is used by many companies to encrypt and decrypt messages. I know that private key is obviously longer than the public key and I'm not sure if it's possible. I need to encrypt client-private-key with RSA-2048 server-public-key. def decryptrsa (decryptkeyfile, ciphertext): from Crypto.PublicKey import RSA from base64 import b64decode key open (decryptkeyfile, 'r').read () rsakey RSA.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |