小编Rob*_*ahl的帖子

C++类型转换操作符代码,无法在visual studio 2012中编译,但在visual studio 2005中运行良好

我正在尝试更新使用visual studio 2005构建的旧项目以使用visual studio 2012,我收到的错误是我无法解决的.

在VS2005下运行良好的代码:

#include <iostream>
#include <string>
#include <sstream>

using std::cout;
using std::wcout;
using std::endl;
using std::wstring;
using std::string;


class Value 
{
public:
    Value(const wstring& value) 
    {
        v = value;
    }

    Value(Value& other)
    {
        this->v = other.v; 
    }

    template<typename T>
    operator T() const
    {
        T reply;
        std::wistringstream is;
        is.str(v);
        is >> reply;
        return reply;
    } 

    operator wstring() const 
    {
        return v;
    }


private:
    wstring v;
};


int main()
{
    Value v(L"Hello World");

    wstring str = v;
    wcout …
Run Code Online (Sandbox Code Playgroud)

c++ rvalue c++11 visual-studio-2012

11
推荐指数
1
解决办法
1324
查看次数

OpenSSL 椭圆曲线读取 DER 形式的私钥

我有一个 DER 形式的 EC 私钥,我想将其转换为 PEM 形式。但我看不懂 DER 表格。

私钥生成如下:

openssl ecparam -param_enc named_curve -check -name "-secp384r1" -genkey -noout -out "params.pem" -outform pem
openssl pkcs8 -in "params.pem" -inform pem -topk8 -nocrypt -out "private.der" -outform der
Run Code Online (Sandbox Code Playgroud)

如果我然后尝试读取私钥

openssl ec -in private.der -inform der 
Run Code Online (Sandbox Code Playgroud)

我收到错误:

read EC key
unable to load Key
4674530924:error:0DFFF0A8:asn1 encoding routines:CRYPTO_internal:wrong tag:/AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-47.140.1/libressl-2.8/crypto/asn1/tasn_dec.c:1144:
4674530924:error:0DFFF03A:asn1 encoding routines:CRYPTO_internal:nested asn1 error:/AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-47.140.1/libressl-2.8/crypto/asn1/tasn_dec.c:717:
4674530924:error:0DFFF03A:asn1 encoding routines:CRYPTO_internal:nested asn1 error:/AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-47.140.1/libressl-2.8/crypto/asn1/tasn_dec.c:646:Field=privateKey, Type=EC_PRIVATEKEY
4674530924:error:10FFF010:elliptic curve routines:CRYPTO_internal:EC lib:/AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-47.140.1/libressl-2.8/crypto/ec/ec_asn1.c:1353:
Run Code Online (Sandbox Code Playgroud)

如果我尝试:

openssl pkcs8 -in private.der -inform der
Run Code Online (Sandbox Code Playgroud)

然后我得到这些错误:

Error reading key …
Run Code Online (Sandbox Code Playgroud)

openssl

2
推荐指数
1
解决办法
1860
查看次数

标签 统计

c++ ×1

c++11 ×1

openssl ×1

rvalue ×1

visual-studio-2012 ×1