【发布时间】:2016-06-30 07:30:22
【问题描述】:
这是我的程序:
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
int main()
{
std::string hash = crypt("asd123","$2a$13$IP4FT4gf123I5bT6o4123123123123nbEXFqo.Oa123");
std::cout << hash;
}
运行它会导致错误
在抛出 'std::logic_error' 的实例后调用终止 what(): basic_string::_M_construct null 无效 中止(核心转储)
但如果我从盐中删除 $ 它运行正常。
【问题讨论】:
-
你有没有尝试阅读一些documentation of
crypt? -
首先,捕获异常。然后 - 在 crypt 的文档中,你会发现它抛出的原因。
标签: c++