169 похожих чатов

Hi. Im trying decrypt an rsa pkcs1 string with private key

file with openssl unit . But after days not successful to do . Any one have example code ?

8 ответов

13 просмотров

Do you have a C language working example? We can help you translate it to Pascal...

Elias C. S.
Do you have a C language working example? We can h...

no . but i write code based on c examples . almost all c example was about to read key in bio format and then get rsa key ... . this is the code but im dont know whats the problem of this code program project1; uses Classes, SysUtils, openssl, base64; function DecryptRSA(const EncryptedData: ansistring; const PrivateKey: ansistring): ansistring; var RSAKey: pRSA; Bio: pBIO; DecryptedLen: integer; DecryptedData: array of byte; begin Bio := BIO_new_mem_buf(@PrivateKey[1], Length(PrivateKey)); RSAKey := PEM_read_bio_PrivateKey(Bio, nil, nil, nil); SetLength(DecryptedData, RSA_size(RSAKey)); DecryptedLen := RSA_private_decrypt(Length(EncryptedData), @EncryptedData[1], @DecryptedData[0], RSAKey, RSA_PKCS1_PADDING); Result := ansistring(Copy(ansistring(DecryptedData), 1, DecryptedLen)); end; var EncryptedString, PrivateKey: ansistring; DecryptedString: ansistring; begin EncryptedString := DecodeStringBase64('...'); PrivateKey := '...'; DecryptedString := DecryptRSA(EncryptedString, PrivateKey); WriteLn('Decrypted Data: ', DecryptedString); end.

Elias C. S.
Do you have a C language working example? We can h...

this was c example https://hayageek.com/rsa-encryption-decryption-openssl-c/

𐇔 𐌁𐌉𐌔𐌂𐌵𐌉𐌕 𐇔
this was c example https://hayageek.com/rsa-encryp...

Did you know this example: https://github.com/fpc/FPCSource/blob/main/packages/openssl/examples/genkeypair.lpr

Elias C. S.
Will take a look and try to help you

thank you 🙏 actually i write code that worked and only problem is code working by not the way should be . take look at this topic i created https://forum.lazarus.freepascal.org/index.php?topic=66394.0 the problem is the way that get rsa from EVP_PKEY

Elias C. S.
Did you know this example: https://github.com/fpc...

this example is generate rsa key and assigned to EVP_PKEY we need to do reverse : load key to EVP_PKEY and get its rsa

Похожие вопросы

Обсуждают сегодня

@MrMiscipitlick А можешь макрос написать, который будет вычислять смещение относительно переданных меток? Просто .label1-.label2, и вернуть значение.
КТ315
35
я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
Заметил в ghci 9.4.8: > :t (<*>) @((->)_) (<*>) @((->)_) :: (w -> (a -> b)) -> (w -> a) -> w -> b Разве не должно (w -> (a -> b)) быть записано как (w -> a -> b)? Это баг, ил...
Михаил
13
А еще в перле можно уже @arr1 + @arr2?
Sergei Zhmylove
53
Any electron dev here?
Sayanth Tezro
12
Подобного рода ;Следующие три строки это директивы ассемблера, ;которые можно не задавать, т.к.работаем в Visual Studio. ;Символ ";" - это начало однострочного комментария ...
Егор Анелькин
3
Привет всем. появился вопрос. Разрабатываю сайт, в данный момент он запущен. Хостинг beget. Добавляю на сайт яндекс метрику с помощью полей client-settings (взято отсюда http...
Andrew
2
Кто-нибудь знает почему SPM клонирует репо целиком? Некоторые репы просто огромные, как та же swift-syntax которая нужна для использования макросов. Сначала подумал, что это...
iMike
6
Подскажите, где смотреть результат выполнения программы? Код: ;.686 ;Система команд процессора 686 ;.MODEL FLAT,stdcall ;Модель памяти плоская, станда...
Егор Анелькин
5
Привет. Я верно понимаю, что в определении класса Монад m — зафиксирован (к тому же поскольку это моноид в категории эндофункторов). Т.е. используя байнд я не могу перемещать...
Arseny
5
Карта сайта