

Here's the phpseclib code to encrypt something with OAEP: use phpseclib3\ Crypt\ PublicKeyLoader PKCS1 keys are loaded in the same way as PKCS8 keys. Plaintext = crypt(ciphertextBytes, sentinel) Sentinel = Random.new().read(key.size_in_bytes())

bDRPrtlRUDDx44wHoEhSDRdy77eiQIgE6z/k6I+ChN1LLttwX0galITxmAYrOBhĬiphertext = "L812/9Y8TSpwErlLR6Bz4J3uR/T5YaqtTtB5jxtD1qazGPI5t15V9drWi58colGOZFeCnGKpCrtQWKk4HWRocQ="ĬiphertextBytes = codebytes(ciphertext.encode( "ascii")) NQIgbYSzn3Py6AasNj6nEtCfB+i1p3F35TK/87DlPSrmAgkCIQDJLhFoj1gbwRbH

HLBNAB69fKwTZFsUNh0CIQEJQRpFCcydunv2bENcN/oBTRw39E8GNv2pIcNxZkcb Ngkp98bMNrzy9AQ1mJGbQZGrpr4c8ZAx3aRNAiEAoxK/MgGeeLui385KJ7ZOYktj JO9DAQIDAQABAkAgkuLEHLaqkWhLgNKagSajeobLS3rPT0Agm0f7k55FXVt743hw GsicURfo+nLW09/0KfOPinhYZ4ouzU+3xC4pSlEp8Ut9FgL0AgqNslNaK34Kq+NZ MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqPfgaTEWEP3S9w0t Key = RSA.import_key( """-BEGIN PRIVATE KEY. $key = $key->withPadding(RSA::ENCRYPTION_PKCS1) Įcho base64_encode($key->encrypt( 'test')) ĭecryption with Python: from Crypto.PublicKey import RSA MEgCQQCo9+BpMRYQ/d元DS2CyJxRF+j6ctbT3/Qp84+KeFhnii7NT7fELilKUSnx $key = PublicKeyLoader::load( '-BEGIN RSA PUBLIC KEY. RSA DecryptionĮncryption with PHP: use phpseclib3\ Crypt\ PublicKeyLoader To disable this behavior do $cipher->disablePadding(). Keep in mind that phpseclib, by default, pads it's ciphertext's. Plaintext = unpad(crypt(ciphertext), AES.block_size) AES-128-CBC DecryptionĮncrypting a string using AES-128-CBC with phpseclib: use phpseclib3\ Crypt\ AES ĭecrypting that same string with Python: from Crypto.Cipher import AESĬiphertext = omhex( "10f42fd95857ed2775cfbc4b471bc213")
