我正在尝试实现从C到PHP的哈希功能,但已经解决了一个问题.真的很感激能得到一些帮助.
这是多次C代码散列:
SHA_CTX ctx;
SHA1_Init(&ctx);
SHA1_Update(&ctx, (const u_int8_t *) salt, strlen(salt));
SHA1_Update(&ctx, (const u_int8_t *) argv[1], strlen(argv[1]));
SHA1_Final(temp, &ctx);
Run Code Online (Sandbox Code Playgroud)
但是它会在循环中再次进行哈希处理,并且我在php中实现了一个棘手的部分:
for (n = 0; n < 2 ; ++n) {
SHA1_Init(&ctx);
SHA1_Update(&ctx, (const u_int8_t *)salt, strlen(salt));
SHA1_Update(&ctx, temp, SHA_DIGEST_LENGTH);
SHA1_Final(temp, &ctx);
}
Run Code Online (Sandbox Code Playgroud)
SHA1_Init在循环中使用相同的context和ctx.我害怕我不能在PHP中做的事情.
这是我目前的PHP代码:
$ctx = hash_init('sha1');
hash_update($ctx, $salt);
hash_update($ctx, 'string');
$pw = hash_final($ctx);
for ($round = 0; $round < 2; ++$round) {
$ctx = hash_init('sha1');
hash_update($ctx, $salt);
hash_update($ctx, $pw);
$pw = hash_final($ctx);
}
Run Code Online (Sandbox Code Playgroud)
从输出中,我可以清楚地看到它在第二次散列时散列与C中的散列不同:
C:
cf584b11970312e4b973bc7b35870d7e019affcd
cb1ea097e844363e4e76d512af4245c10ade1725
PHP:
cf584b11970312e4b973bc7b35870d7e019affcd …Run Code Online (Sandbox Code Playgroud) 我的Grails应用程序中有一个服务.但是我需要在我的应用程序中找到配置以进行某些配置.但是,当我尝试def grailsApplication在我的服务中使用时,它仍然为空.
我的服务是在"服务"下.
class RelationService {
def grailsApplication
private String XML_DATE_FORMAT = "yyyy-MM-dd"
private String token = 'hej123'
private String tokenName
String WebserviceHost = 'xxx'
def getRequest(end_url) {
// Set token and tokenName and call communicationsUtil
setToken();
ComObject cu = new ComObject(tokenName)
// Set string and get the xml data
String url_string = "http://" + WebserviceHost + end_url
URL url = new URL(url_string)
def xml = cu.performGet(url, token)
return xml
}
private def setToken() {
tokenName = grailsApplication.config.authentication.header.name.toString() …Run Code Online (Sandbox Code Playgroud) <?php
echo ltrim('12Hello World', '\x30..\x39');
echo "<br />";
echo ltrim('12Hello World', '0123456789');
Run Code Online (Sandbox Code Playgroud)
给出输出:
ello World
Hello World
Run Code Online (Sandbox Code Playgroud)
为什么?我知道它是一个字符数组,每个字符都被剥离但如果是这样的话,为什么H在第一种情况下删除?
我有一个关于intellij 14.0.3的烦人的bug .问题是它在空行上保留缩进,我不能以任何方式删除该空格.在代码风格下,我没有选中复选框"在空行上保留缩进",并从显示器判断该功能是如何工作的,我会说它会这样做.
但是,它仍然保留缩进,并且在git中创建了坏的差异,因为添加了空格.这是一个错误吗?我可以以任何方式删除它们吗?我试图在我使用的语言和主要语言下取消选中该复选框.他们似乎都没有改变它.
我有一个类,它将处理我之前创建的另一个类的对象数组(工作正常).当我尝试创建List-class的对象时出现问题.
这是list-class的标题:
#ifndef personlistH
#define personlistH
#include "Person.h"
#include <iomanip>
#include <iostream>
#define SIZE 10
namespace std {
class PersonList {
private:
Person persons[SIZE];
int arrnum;
string filename;
public:
Personlist();
};
}
#endif
Run Code Online (Sandbox Code Playgroud)
这是主要功能:
#include <iostream>
#include "PersonList.h"
using namespace std;
int main() {
PersonList personlist;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我的编译器给出的错误如下:
错误:"27\PersonList.h ISO C++禁止声明`Personlist'没有类型"
我已经搜索了答案,但由于我对C++很陌生,所以有点令人困惑,我还没有找到合适的答案.如果你能为我解释这个错误会很棒.
var app = require('express')()
, server = require('http').createServer(app)
, io = require('socket.io').listen(server);
server.use(app.static('public'));
server.listen(3000);
app.get('/', function (req, res) {
res.sendfile('index.html');
});
io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
Run Code Online (Sandbox Code Playgroud)
我只是试图启动非常小的工作项目,但是当涉及到静态内容时我就陷入了困境.我检查了其他类似的线程,但我不知道为什么它对我不起作用.我刚收到这个错误:
server.use(app.static('public'));
^
TypeError: Object function app(req, res){ app.handle(req, res); } has no method 'static'
Run Code Online (Sandbox Code Playgroud)
我想我做错了什么,但我真的不知道是什么.也许我应该尽快去睡觉:)
所以,我现在一直在试用php框架锂,它似乎是一个非常好的框架,但我有一个小问题.我在一个只有6k +文档的集合上运行的查询在php中非常慢,但是当我从终端运行它时速度非常快.
集合中的一个文档可能如下所示:
{
"_id" : ObjectId("504c9a3b6070d8b7ea61938e"),
"startDate" : "Jan 2011",
"episodes" : [
{
"title" : "Series 1, Episode 1",
"airdate" : ISODate("2011-01-20T00:00:00Z"),
"epnum" : "1",
"prodnum" : null,
"seasonnum" : "01",
"link" : "http://www.tvrage.com/10_OClock_Live/episodes/1065007783"
},
{and maybe 20 more},
],
"runTime" : "60 min",
"endDate" : "Apr 2012",
"network" : "Channel 4",
"numberOfEpisodes" : "25 eps",
"title" : "10 O'Clock Live",
"directory" : "10OClockLive",
"country" : "UK",
"tvrage" : "27363"
}
Run Code Online (Sandbox Code Playgroud)
我想获得本月所有的剧集.所以在终端(我使用假值和一个多月)我使用以下查询:
db.series.find({'episodes.airdate': {$gt: ISODate('2012-09-07 00:00:00'), $lt: ISODate('2012-11-01')}}) …Run Code Online (Sandbox Code Playgroud) 您好我正在使用Grails 2.1,我有一点问题,我找不到一个好的解决方案.我正在查询数据库中的某些对象,它返回并按预期排序,但有一个例外,空值是第一个.
这是我可以用来查询数据库的代码:
Object.findAllByObjectTypeAndDateBetween(ObjectType.REGULAR, startDate, stopDate).sort {it.str}
Run Code Online (Sandbox Code Playgroud)
有没有什么方法可以按字符串排序并获取所有空值而不是第一个?我正在寻找一种简单的方法,不是这样的: Grails/Hibernate:如何通过isnull(属性)来命令最后得到NULL?
谢谢.
我正在尝试创建一个非常简单的角度服务:
import { Http, Response } from '@angular/http';
import 'rxjs/add/operator/toPromise';
export class Webservice {
constructor(private http: Http) {
}
getMessages() {
return this.http.get('http://localhost:63962/api/someshittyendpoint').toPromise();
}
}
Run Code Online (Sandbox Code Playgroud)
无论我做什么,我得到以下内容Module not found: Error: Can't resolve 'rxjs/add/operator/toPromise'.
我已经安装了rxjs-compat并验证了该模块实际上是在路径上.我不明白什么是错的?
提前致谢!