python 关于 OpenSSL.crypto 模块验签问题

对接一个接口,在数据发送与接收时需要rsa签名和验签。

采用 OpenSSL.crypto 模块进行签名

签名的主要部分是:

from OpenSSL.crypto import load_privatekey,FILETYPE_PEM,sign,verify

 def tosign(data,private_key):
                    key = load_privatekey(FILETYPE_PEM, private_key)
                    return base64.b64encode(sign(key,data,'sha1'))

def verysign(data,getsign,public_key):
          sign = base64.b64decode(getsign)
                    key = load_certificate(FILETYPE_PEM,public_key)
                    ret = verify(key,sign,data,'sha1')
                    return ret

密钥是”BEGIN RSA PRIVATE KEY --- END RSA PRIVATE KEY”
公钥是 “ BEGIN PUBLIC KEY --- END PUBLIC KEY”

签名是没有问题的,但是验签会报错:[('PEM routines', 'PEM_read_bio', 'no start line')]
对一些加密解密加签的本来就不熟,在 google 后更加蒙蔽了,所以想请问各位大佬指出一下问题,给个解决方案或者一点建议

3个回答

用一个全局队列,进来函数就把当前时间与队头的时间比较,差在限定时间内就返回不执行下面操作,否则就把当前时间塞入队列并继续执行函数下面操作。最后维护一下队列元素的个数就行了。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
无法加载动态库openssl.so

<div class="post-text" itemprop="text"> <p>I just set up PHP and Apache on a Mac 10.8 localhost. So far it works fine. I am now installing Symfony2. When I run the Composer install command, I get the following error :</p> <pre><code>$ curl -s http://getcomposer.org/installer | php #!/usr/bin/env php Some settings on your machine make Composer unable to work properly. Make sure that you fix the issues listed below and run this script again: The openssl extension is missing, which means that secure HTTPS transfers are impossible. If possible you should enable it or recompile php with --with-openssl </code></pre> <p>I uncommented the following line in php.ini :</p> <pre><code>extension=php_openssl.dll </code></pre> <p>But I still get the same error, preceded by this message :</p> <pre><code>PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20131226/php_openssl.dll' - dlopen(/usr/local/lib/php/extensions/no-debug-non-zts-20131226/php_openssl.dll, 9): image not found in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20131226/php_openssl.dll' - dlopen(/usr/local/lib/php/extensions/no-debug-non-zts-20131226/php_openssl.dll, 9): image not found in Unknown on line 0 </code></pre> <p>There's no openssl.so file in my /usr/local/lib/php/extensions/no-debug-non-zts-20131226/ folder indeed. I tried reinstalling php but it made no difference. I googled for hours yet I couldn't find a way to recompile php with --with-openssl. Any help would be of great value.</p> </div>

scrapy出错twisted.python.failure.Failure twisted.internet.error

我是跟这网上视频写的 ``` import scrapy class QsbkSpider(scrapy.Spider): name = 'qsbk' allowed_domains = ['www.qiushibaike.com/'] start_urls = ['https://www.qiushibaike.com/text/'] def parse(self, response): print('='*10) print(response) print('*'*10) ``` 出现 ![图片说明](https://img-ask.csdn.net/upload/201908/06/1565066344_519008.png) 请求头改了还是不行,用requests库爬取又可以

无法加载动态库php_openssl.dll

<div class="post-text" itemprop="text"> <p>I figured out why this is not working, but I don't know how to fix it.</p> <p><a href="https://i.stack.imgur.com/yDmnI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yDmnI.png" alt="Error message"></a></p> <p>At the bottom there is a PHP Warning saying it cannot load the dynamic library because it cannot find it. It is looking in the C: drive when it should be looking in D:\Other\php-7.0.13-Win32-VC14-x64\ext\php_openssl.dll</p> <p>How do I change it so it looks in the right spot? Do I edit the php.ini file? Which part? I've tried looking myself and have come up empty.</p> <p>Many thanks.</p> </div>

python2中requests.post能否做双向认证?需要的证书一般从哪里获得?

如题,纠结了好久了。用socket和openssl方式通过2各pem文件可以实现认证,但是换成requests.post方式就不行了。成功的函数如下: def ssl_request(data=None): import OpenSSL ctx = OpenSSL.SSL.Context(OpenSSL.SSL.SSLv23_METHOD) ctx.use_certificate_file('/Users/username/Work/cert.pem') # 证书 ctx.use_privatekey_file('/Users/username/Work/key-unencrypted.pem') # 密钥 sock = socket.socket() ssock = OpenSSL.SSL.Connection(ctx, sock) ssock.connect(('123.456.789.111', 443)) send_flag = 1 while send_flag == 1: try: ssock.send(data) send_flag = 0 except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError): continue write_flag = 1 while write_flag == 1: try: recv_data = ssock.recv(16384) write_flag = 0 except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError): continue sock.close() return recv_data

安装 tengine异常,求解

请教大神!!! 安装tengine-2.2.0 异常 src/event/ngx_event_openssl.c: In function ‘ngx_ssl_init’: src/event/ngx_event_openssl.c:112:5: error: ‘OPENSSL_config’ is deprecated [-Werror=deprecated-declarations] OPENSSL_config(NULL); ^ In file included from /usr/local/include/openssl/ct.h:13:0, from /usr/local/include/openssl/ssl.h:61, from src/event/ngx_event_openssl.h:15, from src/core/ngx_core.h:85, from src/event/ngx_event_openssl.c:9: /usr/local/include/openssl/conf.h:92:1: note: declared here DEPRECATEDIN_1_1_0(void OPENSSL_config(const char *config_name)) ^ src/event/ngx_event_openssl.c: In function ‘ngx_ssl_rsa512_key_callback’: src/event/ngx_event_openssl.c:753:9: error: ‘RSA_generate_key’ is deprecated [-Werror=deprecated-declarations] key = RSA_generate_key(512, RSA_F4, NULL, NULL); ^ In file included from /usr/local/include/openssl/rsa.h:13:0, from /usr/local/include/openssl/x509.h:31, from /usr/local/include/openssl/ssl.h:50, from src/event/ngx_event_openssl.h:15, from src/core/ngx_core.h:85, from src/event/ngx_event_openssl.c:9: /usr/local/include/openssl/rsa.h:193:1: note: declared here DEPRECATEDIN_0_9_8(RSA *RSA_generate_key(int bits, unsigned long e, void ^ src/event/ngx_event_openssl.c: In function ‘ngx_ssl_dhparam’: src/event/ngx_event_openssl.c:943:11: error: dereferencing pointer to incomplete type ‘DH {aka struct dh_st}’ dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL); ^ src/event/ngx_event_openssl.c: In function ‘ngx_ssl_handshake’: src/event/ngx_event_openssl.c:1166:31: error: dereferencing pointer to incomplete type ‘SSL {aka struct ssl_st}’ if (c->ssl->connection->s3) { ^ src/event/ngx_event_openssl.c: In function ‘ngx_ssl_connection_error’: src/event/ngx_event_openssl.c:1928:21: error: ‘SSL_R_NO_CIPHERS_PASSED’ undeclared (first use in this function) || n == SSL_R_NO_CIPHERS_PASSED /* 182 */ ^ src/event/ngx_event_openssl.c:1928:21: note: each undeclared identifier is reported only once for each function it appears in src/event/ngx_event_openssl.c: In function ‘ngx_ssl_session_cache’: src/event/ngx_event_openssl.c:2122:43: error: passing argument 2 of ‘SSL_CTX_sess_set_get_cb’ from incompatible pointer type [-Werror=incompatible-pointer-types] SSL_CTX_sess_set_get_cb(ssl->ctx, ngx_ssl_get_cached_session); ^ In file included from src/event/ngx_event_openssl.h:15:0, from src/core/ngx_core.h:85, from src/event/ngx_event_openssl.c:9: /usr/local/include/openssl/ssl.h:637:6: note: expected ‘SSL_SESSION * (*)(struct ssl_st *, const unsigned char *, int, int *) {aka struct ssl_session_st * (*)(struct ssl_st *, const unsigned char *, int, int *)}’ but argument is of type ‘SSL_SESSION * (*)(SSL *, u_char *, int, int *) {aka struct ssl_session_st * (*)(struct ssl_st *, unsigned char *, int, int *)}’ void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, ^ src/event/ngx_event_openssl.c: In function ‘ngx_ssl_session_id_context’: src/event/ngx_event_openssl.c:2144:27: error: storage size of ‘md’ isn’t known EVP_MD_CTX md; ^ src/event/ngx_event_openssl.c:2210:5: error: implicit declaration of function ‘EVP_MD_CTX_cleanup’ [-Werror=implicit-function-declaration] EVP_MD_CTX_cleanup(&md); ^ src/event/ngx_event_openssl.c: In function ‘ngx_ssl_session_ticket_key_callback’: src/event/ngx_event_openssl.c:2872:9: error: ‘RAND_pseudo_bytes’ is deprecated [-Werror=deprecated-declarations] RAND_pseudo_bytes(iv, 16); ^ In file included from /usr/local/include/openssl/engine.h:19:0, from src/event/ngx_event_openssl.h:22, from src/core/ngx_core.h:85, from src/event/ngx_event_openssl.c:9: /usr/local/include/openssl/rand.h:47:1: note: declared here DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num)) ^ cc1: all warnings being treated as errors objs/Makefile:827: recipe for target 'objs/src/event/ngx_event_openssl.o' failed make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1 make[1]: Leaving directory '/home/hvm/桌面/Lib/tengine-tengine-2.2.0' Makefile:15: recipe for target 'install' failed make: *** [install] Error 2

安装cryptography报错'openssl/opensslv.h': No such file or directory

aphy.egg-info\PKG-INFO inks to src\cryptography.egg-info\dependency_links.txt to src\cryptography.egg-info\requires.txt mes to src\cryptography.egg-info\top_level.txt e 'src\cryptography.egg-info\SOURCES.txt' plate 'MANIFEST.in' ed directories found matching 'docs\_build' ly-included files matching '*' found under directory 'vectors' e 'src\cryptography.egg-info\SOURCES.txt' ode to build\bdist.win32\egg le 'build\\temp.win32-3.6\\Release\\_padding.c' le 'build\\temp.win32-3.6\\Release\\_constant_time.c' le 'build\\temp.win32-3.6\\Release\\_openssl.c' extension rosoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -ID:\Python3.6.7\include -ID:\Python3.6.7\include "- crosoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files\Window hared" "-IC:\Program Files\Windows Kits\8.1\include\um" "-IC:\Program Files\Windows Kits\8.1\include\winrt" /Tcbuild\temp.win32- .c /Fobuild\temp.win32-3.6\Release\build\temp.win32-3.6\Release\_openssl.obj \Release\_openssl.c(498): fatal error C1083: Cannot open include file: 'openssl/opensslv.h': No such file or directory Program Files\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2

Mac Yosemite,PHP激活openssl扩展

<div class="post-text" itemprop="text"> <p>I have installed PHP 5.5.14.</p> <p>I'm starting to use Yii2, the whole installation process using "composer" working properly.</p> <p>The problem arises when I access "<a href="http://localhost/basic/web/" rel="nofollow">http://localhost/basic/web/</a>" to validate the installation and project creation.</p> <p>At this point an error:</p> <p><strong>PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20121212/php_openssl.dll' - dlopen (/ usr / lib / php / extensions / no-debug-non- zts-20121212 / php_openssl.dll, 9): image not found</strong></p> <p>I'm trying to figure out how to properly activate this librearia.</p> <p>I enabled the extension in the php.ini file, but no luck.</p> <p>Do not know how to fix it :(</p> <p>Thank You!</p> </div>

RSA解密 Decryption error 问题,很迷惑

使用RSA+AES混合加密传输数据的时候,这是request请求时对入参的处理: ``` @Override public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter methodParameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) throws IOException { try { RsaType type = RsaType.NONE; if (methodParameter.getMethod().isAnnotationPresent(RsaSecurityParameter.class)) { //获取注解配置的包含和去除字段 RsaSecurityParameter serializedField = methodParameter.getMethodAnnotation(RsaSecurityParameter.class); //入参是否需要解密 type =serializedField.type(); } if (type.equals(RsaType.ALL) || type.equals(RsaType.ONLY_DECODE)) { String aesKey = ""; HttpHeaders headers = inputMessage.getHeaders(); if(headers.containsKey("Aes-Key")){ List<String> aesKeys = headers.get("Aes-Key"); if(aesKeys.size() == 1){ aesKey = aesKeys.get(0); } } if(StringUtils.isEmpty(aesKey)){ throw new Exception(); } String encrptAesKey = RSAUtils.decryptDataOnJava(aesKey,PRIVATE_KEY); //需要解密 return new MyHttpInputMessage(inputMessage,encrptAesKey); }else{ return inputMessage; } } catch (Exception e) { e.printStackTrace(); return inputMessage; } } ``` 这是响应时的处理: ``` public T beforeBodyWrite(T body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) { try { RsaType type = RsaType.NONE; if (returnType.getMethod().isAnnotationPresent(RsaSecurityParameter.class)) { //获取注解配置的包含和去除字段 RsaSecurityParameter serializedField = returnType.getMethodAnnotation(RsaSecurityParameter.class); //出参是否需要加密 type =serializedField.type(); } if (type.equals(RsaType.ALL) || type.equals(RsaType.ONLY_ENCODE)) { //需要加密 String aesKey = ""; HttpHeaders headers = request.getHeaders(); if(headers.containsKey("Aes-Key")){ List<String> aesKeys = headers.get("Aes-Key"); if(aesKeys.size() == 1){ aesKey = aesKeys.get(0); } } if(StringUtils.isEmpty(aesKey)){ throw new Exception(); } String encrptAesKey = RSAUtils.decryptDataOnJava(aesKey,PRIVATE_KEY); //使用aesKey加密响应数据 return (T) AESUtils.aesEncrypt(JSON.toJSONString(body), encrptAesKey); }else{ return body; } } catch (Exception e) { e.printStackTrace(); return body; } } ``` 这两块代码,关于从请求头取出用RSA加密处理后的Aes-Key是一致的。DEBUG打断点观察取到的数据也是一致的,但是在使用RSA解密时,入参的解密是正常没问题的。出参这一块的解密就报javax.crypto.BadPaddingException: Decryption error这个错误。 这是入参时候的处理,这边aes-key是正常解密出来了的。 ![图片说明](https://img-ask.csdn.net/upload/201910/23/1571826872_2395.png) 这是出参时候的处理,这边aes-key解密就报错了。 ![图片说明](https://img-ask.csdn.net/upload/201910/23/1571827079_319247.png) 包括我在本地调用测试方法也是正常解密的不会报错的。 有没有大神帮忙解释一下?

nginx1.17.4中编译openssl报错

nginx1.17.4中编译openssl报错 file included from /usr/include/openssl/ssl.h:149:0, from src/event/ngx_event_openssl.h:15, from src/core/ngx_core.h:83, from src/core/nginx.c:9: /usr/include/openssl/comp.h:36:5: 错误:未知的类型名‘COMP_METHOD’ COMP_METHOD *meth; ^ /usr/include/openssl/comp.h:44:24: 错误:未知的类型名‘COMP_METHOD’ COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); ^ /usr/include/openssl/comp.h:50:1: 错误:未知的类型名‘COMP_METHOD’ COMP_METHOD *COMP_rle(void); ^ /usr/include/openssl/comp.h:51:1: 错误:未知的类型名‘COMP_METHOD’ COMP_METHOD *COMP_zlib(void); ^ In file included from src/event/ngx_event_openssl.h:15:0, from src/core/ngx_core.h:83, from src/core/nginx.c:9: /usr/include/openssl/ssl.h:879:5: 错误:未知的类型名‘COMP_METHOD’ COMP_METHOD *method; ^ In file included from /usr/include/openssl/ssl.h:1655:0, from src/event/ngx_event_openssl.h:15, from src/core/ngx_core.h:83, from src/core/nginx.c:9: /usr/include/openssl/dtls1.h:257:35: 错误:字段‘recordinfo’的类型不完全 struct bio_dgram_sctp_rcvinfo recordinfo; ^ In file included from src/event/ngx_event_openssl.h:15:0, from src/core/ngx_core.h:83, from src/core/nginx.c:9: /usr/include/openssl/ssl.h:2468:1: 错误:未知的类型名‘COMP_METHOD’ const COMP_METHOD *SSL_get_current_compression(SSL *s); ^ /usr/include/openssl/ssl.h:2469:1: 错误:未知的类型名‘COMP_METHOD’ const COMP_METHOD *SSL_get_current_expansion(SSL *s); ^ /usr/include/openssl/ssl.h:2470:1: 错误:未知的类型名‘COMP_METHOD’ const char *SSL_COMP_get_name(const COMP_METHOD *comp); ^ /usr/include/openssl/ssl.h:2475:45: 错误:未知的类型名‘COMP_METHOD’ int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm);

wpa_supplicant编译时出现 undefined reference to `sha256_vector'

CC ../src/drivers/drivers.c CC ../src/l2_packet/l2_packet_linux.c ../src/wps/wps_common.o: In function `wps_derive_keys': /home/atheros/Atheros-P2P/wpa_supplicant-2.1/wpa_supplicant/../src/wps/wps_common.c:101: undefined reference to `sha256_vector' ../src/wps/wps_enrollee.o: In function `wps_process_pubkey': /home/atheros/Atheros-P2P/wpa_supplicant-2.1/wpa_supplicant/../src/wps/wps_enrollee.c:519: undefined reference to `sha256_vector' ../src/crypto/tls_openssl.o: In function `openssl_tls_cert_event': /home/atheros/Atheros-P2P/wpa_supplicant-2.1/wpa_supplicant/../src/crypto/tls_openssl.c:1346: undefined reference to `sha256_vector' ../src/crypto/tls_openssl.o: In function `tls_verify_cb': /home/atheros/Atheros-P2P/wpa_supplicant-2.1/wpa_supplicant/../src/crypto/tls_openssl.c:1421: undefined reference to `sha256_vector' ../src/crypto/crypto_openssl.o: In function `crypto_hash_init': /home/atheros/Atheros-P2P/wpa_supplicant-2.1/wpa_supplicant/../src/crypto/crypto_openssl.c:620: undefined reference to `EVP_sha256' ../src/crypto/crypto_openssl.o: In function `hmac_sha256_vector': /home/atheros/Atheros-P2P/wpa_supplicant-2.1/wpa_supplicant/../src/crypto/crypto_openssl.c:754: undefined reference to `EVP_sha256' collect2: error: ld returned 1 exit status make: *** [wpa_supplicant] Error 1 root@atheros:/home/atheros/Atheros-P2P/wpa_supplicant-2.1/wpa_supplicant#

php.ini文件 - openssl

<div class="post-text" itemprop="text"> <p>in php.ini file </p> <p>there is a line like that</p> <pre><code> extension=php_openssl.dll </code></pre> <p>which define OpenSSL</p> <p>but there is one more line which is header of this extension something like that</p> <p>[PHPOpenSSL]</p> <p>what was it ? what was this[text] ty</p> </div>

OpenSSL未在PHP模块下列出,但在configure命令中显示

<div class="post-text" itemprop="text"> <p>PHP 5.2.12<br> OS X 10.5.8</p> <p>If I compile PHP from source with the following configure command</p> <pre><code>./configure --disable-all --with-openssl=shared,/opt/local </code></pre> <p>it succeeds. However, after a <code>make</code> and <code>make install</code>,</p> <pre><code>php -m </code></pre> <p>does <em>not</em> list the openssl module.</p> <p>Based on what I've read, I <em>think</em> it may be due to multiple installs of the openssl library. Installing the latest version of openssl from source and trying to specify the path in the configure command, <code>--with-openssl=/usr/local</code>, always results in the following error:</p> <pre><code>Undefined symbols: "_EVP_CIPHER_CTX_block_size", referenced from: _zif_openssl_seal in openssl.o ld: symbol(s) not found collect2: ld returned 1 exit status make: *** [sapi/cgi/php-cgi] Error 1 </code></pre> <p>I've tried a few different variations on the path with no luck.</p> <p>Based on <a href="http://blog.yimingliu.com/2009/02/24/missing-library-symbols-while-compiling-php-528/" rel="nofollow noreferrer">http://blog.yimingliu.com/2009/02/24/missing-library-symbols-while-compiling-php-528/</a>, I've also tried editing the Makefile so that MH_BUNDLE_FLAGS comes later in the compilation line.</p> <p>After spending a good portion of the day on this issue, I'm at a loss.</p> <p>Any suggestions?</p> <p>Ideally, I'd like to be using the compiled and most recent version of OpenSSL. But at this point, I'm willing to accept whatever works.</p> </div>

php openssl无法定位序数,求大神看下

![图片说明](https://img-ask.csdn.net/upload/201701/12/1484204950_22850.png) 目前已试了将wamp2\bin\php\php5.3.10下的ssleay32.dll、libeay32.dll、php_openssl.dll,复制到c:/window/system32/下了,复制后重启了wamp,但运行openssl.exe还是报这个错

编译openssh出现报错configure: error: OpenSSL library not found.

checking if getpgrp accepts zero args... yes checking openssl/opensslv.h usability... yes checking openssl/opensslv.h presence... yes checking for openssl/opensslv.h... yes checking OpenSSL header version... 1010104f (OpenSSL 1.1.1d 10 Sep 2019) checking for OpenSSL_version... no checking for OpenSSL_version_num... no checking OpenSSL library version... not found configure: error: OpenSSL library not found. [root@localhost openssh-8.1p1]# 编译openssh时,出现这个问题,就在执行 ./configure弹出的 电脑里面有两个openssl [root@localhost openssh-8.1p1]# /usr/local/bin/openssl version OpenSSL 1.1.1d 10 Sep 2019 [root@localhost openssh-8.1p1]# /bin/openssl version OpenSSL 1.0.1e-fips 11 Feb 2013 [root@localhost openssh-8.1p1]# 上面是编译安装的,在/usr/local下面,一个是系统自带的在/usr下面。请问怎么将这个编译的openssh装上去,出现这个报错 怎么解决

使用c#中的公钥加密数据,并使用php中的私钥解密数据

<div class="post-text" itemprop="text"> <p>I'm trying to encrypt a JSON string in C# en decrypt it in PHP by using OpenSSL RSA.</p> <p>The following code is in C#:</p> <pre><code>public static string EncryptData(string data) { string key = @"-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC/J/txQvYBm5iOHRRRtgdXd5hq DEavxy5OExSiwjJgOgT72A9GX7+E7QYfhUZJTGtf+/J84tuJPx6/Ff1dZa1XRW84 /n5m7fw93CTVwpfRFi0Owenor44zgk6ABSfMlCzwGfdcS8AFiWCFUBpatKte6PaO /WfYK7qz/5faSp3FawIDAQAB -----END PUBLIC KEY-----"; OpenSSL.Crypto.CryptoKey pKey = OpenSSL.Crypto.CryptoKey.FromPublicKey(key, null); OpenSSL.Crypto.RSA rsa = pKey.GetRSA(); byte[] encryptedData = rsa.PublicEncrypt (Encoding.UTF8.GetBytes(data), OpenSSL.Crypto.RSA.Padding.PKCS1); rsa.Dispose(); return Convert.ToBase64String (encryptedData); } </code></pre> <p>then I send the encoded <code>encryptedData</code> to PHP and put it into the <code>PrivateKeyDecrypt</code> function.</p> <p>Code in PHP:</p> <pre><code>&lt;?php // include the lib //require_once('OpenSSL.php'); $ssl = new OpenSSL(); $ssl-&gt;loadPrivateKeyWithoutPath('-----BEGIN RSA PRIVATE KEY----- MIICXQIBAAKBgQC+wVuIECnd7dvt7yqoElg4DL8jSKFpUavKfviSBE2Z+5z5YWnf i4mp/r0P0jVbE+dfqReaIr4UOt//hPvwvioAJ576KPOCTYZiIGehkqafGWS+01wH nAPSj/C7Xt7F9Mh5McH4CnBR5VN93KKZtQtfNsNPPBdXwQuquONOUgUgTwIDAQAB AoGAIQkvpvLVrV/CVQS0qIL00FA00hGEEs9YJyuyNOeV4PMYjn/2bAaogs5hQ9ot 72YVDhYkxkb6EFrZ7FDFqT3l2/BpQEsJ6/GQq2gX0rYGfJ5sWrN+KIuSJr4FWSN+ LrvIEr35hKHY6mytiQg9D58b5kSjaB9ea/qhh/hJL2VfWGECQQDlBBJsccR2ZzzH QN5omwFrUuxnqraY5LyZB8xUnqo9iDULO+GTcW/5eO9TBoWuDf1Ul3Snts9Tb+uD UYL1y5onAkEA1Ts182anQHCjUtp2hooLjDcOvIK3gi5TchqHW6T4K3tNtnbfOB9P gMNgcKljjXlQXl3ornvLTYBC483MS4RpmQJAZMiS9whmBhlOpP1GI1C7oih/Auwc qVJYMRw+bqrYjnWnqkby8XkFZwsyfx4qrDtZ1eVFIB2SRczGHyc688JjFwJBAIxa lx6J2VlfSwIEbrQMNaGrs/V9jVERMTgQIjy+j+P/G54ZDMEiSvCUqew+cxryWWZk Jf6D2cQ/wsez9N9YXzECQQDMH6jS9vp7aabI2UKy5RhTqvP6kRmi28/GHb/8QrFx tldiw2THvc4+4QT9tuv5OA6xRnEO5mt5u3vFHciqeRR7 -----END RSA PRIVATE KEY-----'); public function PrivateKeyDecrypt($raw_data, $base64 = TRUE) { if ($this-&gt;privateKey == NULL) trigger_error("Private key has not been specified.", E_USER_ERROR); if (!openssl_private_decrypt(($base64) ? base64_decode($raw_data) : $raw_data, $decrypted_data, $this-&gt;privateKey, $this-&gt;padding)) trigger_error("Unable to decrypt data.", E_USER_ERROR); return $decrypted_data; } </code></pre> <p>The error I get when I call the <code>PrivateKeyDecrypt</code> function is: </p> <pre><code>FATAL ERROR: unable to decrypt data in ... </code></pre> <p>Does anyone have any idea what causes this error? </p> </div>

vc++ .h文件中只有对应的目录怎么处理

最近gsoap调用openssl来处理加密,下载openssl之后,直接解压缩,在vc的附加目录中包含了openssl的include目录 然后编译程序,提示bio.h报语法错误 bio.h文件的内容是 ../../crypto/bio/bio.h 是一个目录,而在这个目录里面的bio.h,才是真正想要的bio.h文件 想问的就是在VC中,要怎么处理,程序才能够自动识别这是个目录,并且跳转到相应的目录然后自动打开这个bio.h 备注:不能把源代码 ../../crypto/bio/bio.h 更改成 #include"../../crypto/bio/bio.h" 应为还有20多个.h文件都一模一样,这么改我岂不得累死

sha1的go与python和openssl的不同

<div class="post-text" itemprop="text"> <p>I am trying to build a base64 encoded sha1 hash in go but the result i am getting is very different to the results of other programming languages</p> <pre><code>package main import ( "crypto/sha1" "encoding/base64" "fmt" ) func main() { c := sha1.New() input := []byte("hello") myBytes := c.Sum(input) fmt.Println(base64.StdEncoding.EncodeToString(base64.StdPadding)) } </code></pre> <p>This Go Code prints out <code>aGVsbG/aOaPuXmtLDTJVv++VYBiQr9gHCQ==</code></p> <p>My Python Code Looks like this</p> <pre><code>import hashlib import base64 print(base64.b64encode(hashlib.sha1('hello').digest())) </code></pre> <p>And outputs <code>qvTGHdzF6KLavt4PO0gs2a6pQ00=</code></p> <p>My bash command for comparison looks like this</p> <pre><code>echo -n hello| openssl dgst -sha1 -binary |base64 </code></pre> <p>And outputs this <code>qvTGHdzF6KLavt4PO0gs2a6pQ00=</code></p> <p>Which lets me assume that the python code is doing everything correct. But why does go prints another result. Where is my mistake?</p> <p>Thnx in advance</p> </div>

小白求助:在mac的anaconda 终端里输入pip更新的代码后更新失败并出现一长段代码。

在mac的anaconda 终端里输入pip更新的代码后更新失败并出现一长段代码。 `Traceback (most recent call last): File "/opt/anaconda3/lib/python3.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 304, in recv_into return self.connection.recv_into(*args, **kwargs) File "/opt/anaconda3/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1822, in recv_into self._raise_ssl_error(self._ssl, result) File "/opt/anaconda3/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1622, in _raise_ssl_error raise WantReadError() OpenSSL.SSL.WantReadError During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/anaconda3/lib/python3.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 304, in recv_into return self.connection.recv_into(*args, **kwargs) File "/opt/anaconda3/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1822, in recv_into self._raise_ssl_error(self._ssl, result) File "/opt/anaconda3/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1622, in _raise_ssl_error raise WantReadError() OpenSSL.SSL.WantReadError `` 尝试过三种更新代码: 1、python -m pip install --upgrade pip 2、python -m pip install -U --force-reinstall pip 3、pip install --user --upgrade pip 均失败。 google 百度了很多经验贴,换个网络/多次尝试都无果。 macbook pro 2019 anaconda python 3.7.4 pip 19.2.3 求助求助!~

尝试使用PHP中的shell_exec通过openssl创建证书

<div class="post-text" itemprop="text"> <p>I'm actually working in a small project for myself, is a Web Application that creates Certificate Signing Request also the certificate <code>.pem/.crt</code> and its <code>.key</code>.</p> <p>The actual problem is that I'm trying to run:</p> <pre><code>shell_exec(openssl ca -config ../openssl.cnf -in $CSR_FILE -out $CRT_FILE) </code></pre> <p>And I find the problem that after running this command is asking for my CA passphrase, and later on answering Yes twice to accept the creation of the certificate. I can't figure it out how to make it work. I've been stuck with that for almost three days, neither Google or Stack Overflow has an anwser.</p> <p>I've tried to run the command and add another <code>shell_exec(passphrase)</code> also, passing passphrase and "y" twice this way.</p> <pre><code>shell_exec("openssl....","passphrase","y","y") </code></pre> <p>Thank you very much, i appreciate all help.</p> </div>

java jdk 8 帮助文档 中文 文档 chm 谷歌翻译

JDK1.8 API 中文谷歌翻译版 java帮助文档 JDK API java 帮助文档 谷歌翻译 JDK1.8 API 中文 谷歌翻译版 java帮助文档 Java最新帮助文档 本帮助文档是使用谷

软件测试2小时入门

本课程内容系统、全面、简洁、通俗易懂,通过2个多小时的介绍,让大家对软件测试有个系统的理解和认识,具备基本的软件测试理论基础。 主要内容分为5个部分: 1 软件测试概述,了解测试是什么、测试的对象、原则、流程、方法、模型;&nbsp; 2.常用的黑盒测试用例设计方法及示例演示;&nbsp; 3 常用白盒测试用例设计方法及示例演示;&nbsp; 4.自动化测试优缺点、使用范围及示例‘;&nbsp; 5.测试经验谈。

汽车行驶工况构建2019 D题.zip

1. 标记0与0之间的片段位置 2.标记所之间的毛刺数的位置 3.去掉毛刺数据 速度 并生成 新的数组 4.标记时间段 5. 0与0之间 如果有不连续的时间片段 置零 先找到时间间隔 再看间隔时间对应

Python+OpenCV计算机视觉

Python+OpenCV计算机视觉系统全面的介绍。

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

专为程序员设计的数学课

<p> 限时福利限时福利,<span>15000+程序员的选择!</span> </p> <p> 1、原价 115 元,限时特价仅需 49 元!<br> 2、购课后添加学习助手(微信号:csdnxy68),按提示消息领取编程大礼包!并获取讲师答疑服务! </p> <p> <br> </p> <p> 套餐中一共包含5门程序员必学的数学课程(共47讲) </p> <p> 课程1:《零基础入门微积分》 </p> <p> 课程2:《数理统计与概率论》 </p> <p> 课程3:《代码学习线性代数》 </p> <p> 课程4:《数据处理的最优化》 </p> <p> 课程5:《马尔可夫随机过程》 </p> <p> <br> </p> <p> 哪些人适合学习这门课程? </p> <p> 1)大学生,平时只学习了数学理论,并未接触如何应用数学解决编程问题; </p> <p> 2)对算法、数据结构掌握程度薄弱的人,数学可以让你更好的理解算法、数据结构原理及应用; </p> <p> 3)看不懂大牛代码设计思想的人,因为所有的程序设计底层逻辑都是数学; </p> <p> 4)想学习新技术,如:人工智能、机器学习、深度学习等,这门课程是你的必修课程; </p> <p> 5)想修炼更好的编程内功,在遇到问题时可以灵活的应用数学思维解决问题。 </p> <p> <br> </p> <p> 在这门「专为程序员设计的数学课」系列课中,我们保证你能收获到这些:<br> <br> <span> </span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">①价值300元编程课程大礼包</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">②应用数学优化代码的实操方法</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">③数学理论在编程实战中的应用</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">④程序员必学的5大数学知识</span> </p> <p class="ql-long-24357476"> <span class="ql-author-24357476">⑤人工智能领域必修数学课</span> </p> <p> <br> 备注:此课程只讲程序员所需要的数学,即使你数学基础薄弱,也能听懂,只需要初中的数学知识就足矣。<br> <br> 如何听课? </p> <p> 1、登录CSDN学院 APP 在我的课程中进行学习; </p> <p> 2、登录CSDN学院官网。 </p> <p> <br> </p> <p> 购课后如何领取免费赠送的编程大礼包和加入答疑群? </p> <p> 购课后,添加助教微信:<span> csdnxy68</span>,按提示领取编程大礼包,或观看付费视频的第一节内容扫码进群答疑交流! </p> <p> <img src="https://img-bss.csdn.net/201912251155398753.jpg" alt=""> </p>

微信公众平台开发入门

本套课程的设计完全是为初学者量身打造,课程内容由浅入深,课程讲解通俗易懂,代码实现简洁清晰。通过本课程的学习,学员能够入门微信公众平台开发,能够胜任企业级的订阅号、服务号、企业号的应用开发工作。 通过本课程的学习,学员能够对微信公众平台有一个清晰的、系统性的认识。例如,公众号是什么,它有什么特点,它能做什么,怎么开发公众号。 其次,通过本课程的学习,学员能够掌握微信公众平台开发的方法、技术和应用实现。例如,开发者文档怎么看,开发环境怎么搭建,基本的消息交互如何实现,常用的方法技巧有哪些,真实应用怎么开发。

4小时玩转微信小程序——基础入门与微信支付实战

这是一个门针对零基础学员学习微信小程序开发的视频教学课程。课程采用腾讯官方文档作为教程的唯一技术资料来源。杜绝网络上质量良莠不齐的资料给学员学习带来的障碍。 视频课程按照开发工具的下载、安装、使用、程序结构、视图层、逻辑层、微信小程序等几个部分组织课程,详细讲解整个小程序的开发过程

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

IE主页被篡改修复

IE主页修复。IE主页被篡改修复。一键修复IE主页

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

土豆SDK(Java版)-非官方

由于土豆SDK一直建设中,最近几天抽空写了一套java的SDK。包含了现有的所有请求协议。本套SDK中仅提供了oAuth的方式(引用oAuth.net的java版示例),并没有在框架中实现,涉及到登录

Java8零基础入门视频教程

这门课程基于主流的java8平台,由浅入深的详细讲解了java SE的开发技术,可以使java方向的入门学员,快速扎实的掌握java开发技术!

【数据结构与算法综合实验】欢乐连连看(C++ & MFC)案例

这是武汉理工大学计算机学院数据结构与算法综合实验课程的第三次项目:欢乐连连看(C++ & MFC)迭代开发代码。运行环境:VS2017。已经实现功能:开始游戏、消子、判断胜负、提示、重排、计时、帮助。

数学建模竞赛D题“汽车行驶工况构建

第十六届“华为杯”数学建模竞赛D题“汽车行驶工况构建”论文。论文获得比赛国家二等奖,论文为原创,仅供参考。 关键词:数据处理;降维;聚类。

Vue.js 2.0之全家桶系列视频课程

基于新的Vue.js 2.3版本, 目前新全的Vue.js教学视频,让你少走弯路,直达技术前沿! 1. 包含Vue.js全家桶(vue.js、vue-router、axios、vuex、vue-cli、webpack、ElementUI等) 2. 采用笔记+代码案例的形式讲解,通俗易懂

Android音视频开发全套

Android平台音视频开发全套,涉及:FFmpeg软解码解码、Mediacodec硬解码编码、Openssl音频播放、OpenGL ES视频渲染、RTMP推流等核心重要知识点。

设计模式(JAVA语言实现)--20种设计模式附带源码

课程亮点: 课程培训详细的笔记以及实例代码,让学员开始掌握设计模式知识点 课程内容: 工厂模式、桥接模式、组合模式、装饰器模式、外观模式、享元模式、原型模型、代理模式、单例模式、适配器模式 策略模式、模板方法模式、观察者模式、迭代器模式、责任链模式、命令模式、备忘录模式、状态模式、访问者模式 课程特色: 笔记设计模式,用笔记串连所有知识点,让学员从一点一滴积累,学习过程无压力 笔记标题采用关键字标识法,帮助学员更加容易记住知识点 笔记以超链接形式让知识点关联起来,形式知识体系 采用先概念后实例再应用方式,知识点深入浅出 提供授课内容笔记作为课后复习以及工作备查工具 部分图表(电脑PC端查看):

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

想学好JAVA必须要报两万的培训班吗? Java大神勿入 如果你: 零基础想学JAVA却不知道从何入手 看了一堆书和视频却还是连JAVA的环境都搭建不起来 囊中羞涩面对两万起的JAVA培训班不忍直视 在职没有每天大块的时间专门学习JAVA 那么恭喜你找到组织了,在这里有: 1. 一群志同道合立志学好JAVA的同学一起学习讨论JAVA 2. 灵活机动的学习时间完成特定学习任务+每日编程实战练习 3. 热心助人的助教和讲师及时帮你解决问题,不按时完成作业小心助教老师的家访哦 上一张图看看前辈的感悟: &nbsp; &nbsp; 大家一定迫不及待想知道什么是极简JAVA学习营了吧,下面就来给大家说道说道: 什么是极简JAVA学习营? 1. 针对Java小白或者初级Java学习者; 2. 利用9天时间,每天1个小时时间; 3.通过 每日作业 / 组队PK / 助教答疑 / 实战编程 / 项目答辩 / 社群讨论 / 趣味知识抢答等方式让学员爱上学习编程 , 最终实现能独立开发一个基于控制台的‘库存管理系统’ 的学习模式 极简JAVA学习营是怎么学习的? &nbsp; 如何报名? 只要购买了极简JAVA一:JAVA入门就算报名成功! &nbsp;本期为第四期极简JAVA学习营,我们来看看往期学员的学习状态: 作业看这里~ &nbsp; 助教的作业报告是不是很专业 不交作业打屁屁 助教答疑是不是很用心 &nbsp; 有奖抢答大家玩的很嗨啊 &nbsp; &nbsp; 项目答辩终于开始啦 &nbsp; 优秀者的获奖感言 &nbsp; 这是答辩项目的效果 &nbsp; &nbsp; 这么细致的服务,这么好的氛围,这样的学习效果,需要多少钱呢? 不要1999,不要199,不要99,只要9.9 是的你没听错,只要9.9以上所有就都属于你了 如果你: 1、&nbsp;想学JAVA没有基础 2、&nbsp;想学JAVA没有整块的时间 3、&nbsp;想学JAVA没有足够的预算 还等什么?赶紧报名吧,抓紧抢位,本期只招300人,错过只有等时间待定的下一期了 &nbsp; 报名请加小助手微信:eduxy-1 &nbsp; &nbsp;

2019 AI开发者大会

2019 AI开发者大会(AI ProCon 2019)是由中国IT社区CSDN主办的AI技术与产业年度盛会。多年经验淬炼,如今蓄势待发:2019年9月6-7日,大会将有近百位中美顶尖AI专家、知名企业代表以及千余名AI开发者齐聚北京,进行技术解读和产业论证。我们不空谈口号,只谈技术,诚挚邀请AI业内人士一起共铸人工智能新篇章!

web网页制作期末大作业

分享思维,改变世界. web网页制作,期末大作业. 所用技术:html css javascript 分享所学所得

手把手实现Java图书管理系统(附源码)

【超实用课程内容】 本课程演示的是一套基于Java的SSM框架实现的图书管理系统,主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的java人群。详细介绍了图书管理系统的实现,包括:环境搭建、系统业务、技术实现、项目运行、功能演示、系统扩展等,以通俗易懂的方式,手把手的带你从零开始运行本套图书管理系统,该项目附带全部源码可作为毕设使用。 【课程如何观看?】 PC端:https://edu.csdn.net/course/detail/27513 移动端:CSDN 学院APP(注意不是CSDN APP哦) 本课程为录播课,课程2年有效观看时长,大家可以抓紧时间学习后一起讨论哦~ 【学员专享增值服务】 源码开放 课件、课程案例代码完全开放给你,你可以根据所学知识,自行修改、优化 下载方式:电脑登录https://edu.csdn.net/course/detail/27513,点击右下方课程资料、代码、课件等打包下载

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

2019 Python开发者日-培训

本次活动将秉承“只讲技术,拒绝空谈”的理念,邀请十余位身处一线的Python技术专家,重点围绕Web开发、自动化运维、数据分析、人工智能等技术模块,分享真实生产环境中使用Python应对IT挑战的真知灼见。此外,针对不同层次的开发者,大会还安排了深度培训实操环节,为开发者们带来更多深度实战的机会。

C++语言基础视频教程

C++语言基础视频培训课程:本课与主讲者在大学开出的程序设计课程直接对接,准确把握知识点,注重教学视频与实践体系的结合,帮助初学者有效学习。本教程详细介绍C++语言中的封装、数据隐藏、继承、多态的实现等入门知识;主要包括类的声明、对象定义、构造函数和析构函数、运算符重载、继承和派生、多态性实现等。 课程需要有C语言程序设计的基础(可以利用本人开出的《C语言与程序设计》系列课学习)。学习者能够通过实践的方式,学会利用C++语言解决问题,具备进一步学习利用C++开发应用程序的基础。

零基础学C#编程—C#从小白到大咖

本课程从初学者角度出发,提供了C#从入门到成为程序开发高手所需要掌握的各方面知识和技术。 【课程特点】 1 由浅入深,编排合理; 2 视频讲解,精彩详尽; 3 丰富实例,轻松易学; 4 每章总结配有难点解析文档。 15大章节,228课时,1756分钟与你一同进步!

编程实现学生基本信息管理程序

编程实现学生基本信息管理程序。学生基本信息包括:学号、姓名、性别、年龄、班级、学院、专业等。具体实现的管理功能如下: (1) 输入并显示多个学生的基本信息; (2) 可根据需要实现学生信息的添加; (

android 漂亮的UI界面 完整的界面设计

声明:这也是我学习时在网上下载的,鉴于分享精神,并且觉得很不错才上传上来的。。。。。 android 漂亮的UI界面 完整的界面设计 这是一个完整的UI设计,但是没写动作,这是一个公司程序员的公司任务

Anaconda详细安装及使用教程(带图文)

Anacond的介绍 Anaconda指的是一个开源的Python发行版本,其包含了conda、Python等180多个科学包及其依赖项。 因为包含了大量的科学包,Anaconda 的下载文件比较大(约 531 MB),如果只需要某些包,或者需要节省带宽或存储空间,也可以使用Miniconda这个较小的发行版(仅包含conda和 Python)。 Conda是一个开源的包、环境管理器,可以用于...

DirectX修复工具V4.0增强版

DirectX修复工具(DirectX Repair)是一款系统级工具软件,简便易用。本程序为绿色版,无需安装,可直接运行。 本程序的主要功能是检测当前系统的DirectX状态,如果发现异常则进行修复

相关热词 c#跨线程停止timer c#批量写入sql数据库 c# 自动安装浏览器 c#语言基础考试题 c# 偏移量打印是什么 c# 绘制曲线图 c#框体中的退出函数 c# 按钮透明背景 c# idl 混编出错 c#在位置0处没有任何行
立即提问