小编CSc*_*ulz的帖子

MD5哈希是不同的

我不知道如何从php到java实现这几行.

$varInHex = "\x22\x33\xAd\xB5\x2b\xE6\x22\x33\x12\x36\x22\x31\xCA\x22\x11\x41\x62\x21\x22\x01\x55\x22\x71\x42\x10\x36";<br/><br/>
$result = md5($varInHex);
echo $result;
Run Code Online (Sandbox Code Playgroud)

好吧,我试图转换它,但我得到了不同的结果!

byte[] seq20 = new byte[]{(byte)0x22,(byte)...etc...};
String str = seq20.toString();
String result = md5(str);
System.out.println(result);

public static String md5(String source) {
    try {
        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] bytes = md.digest(source.getBytes("UTF-8"));
        return getString(bytes);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

private static String getString(byte[] bytes) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < bytes.length; i++) {
        byte b = bytes[i];
        String hex = …
Run Code Online (Sandbox Code Playgroud)

php java string hex md5

6
推荐指数
2
解决办法
6343
查看次数

Android中SHA1哈希实现的问题

我有两个用于计算SHA1的小片段.

一个是非常快但似乎它是不正确的,另一个是非常缓慢但正确的.
我认为FileInputStream转换ByteArrayInputStream是问题所在.

快速版:

MessageDigest md = MessageDigest.getInstance("SHA1");
FileInputStream fis = new FileInputStream("path/to/file.exe");
ByteArrayInputStream byteArrayInputStream =
    new ByteArrayInputStream(fis.toString().getBytes());
DigestInputStream dis = new DigestInputStream(byteArrayInputStream, md);
BufferedInputStream bis = new BufferedInputStream(fis);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

int ch;
while ((ch = dis.read()) != -1) {
    byteArrayOutputStream.write(ch);
}

byte[] newInput = byteArrayOutputStream.toByteArray();
System.out.println("in digest : " +
    byteArray2Hex(dis.getMessageDigest().digest()));

byteArrayOutputStream = new ByteArrayOutputStream();
DigestOutputStream digestOutputStream =
    new DigestOutputStream(byteArrayOutputStream, md);
digestOutputStream.write(newInput);

System.out.println("out digest: " +
    byteArray2Hex(digestOutputStream.getMessageDigest().digest()));
System.out.println("length: " + 
    new String( …
Run Code Online (Sandbox Code Playgroud)

java hash android sha1 stream

6
推荐指数
2
解决办法
5271
查看次数

在 SONAR 中使用 Jacoco 的 IT 测试覆盖率为 0%

我在用:

SONAR v.3.2(它有jacoco)

Maven 3.0.4

遵循“ http://johndobie.blogspot.in/2012/05/easy-unit-and-integration-code-coverage.html#comment-form ”以获得单元和IT测试的单独代码覆盖率。但 IT 测试覆盖率显示为 0%。它生成单独的 jacoco-unit.exec (44kb) 和 jacoco-it.exec (14kb),但覆盖率仅显示在 SONAR 上的单元测试中。

日志显示为:

[INFO] [13:10:23.515] Sensor SquidSensor done: 9437 ms
[INFO] [13:10:23.515] Sensor JaCoCoSensor...
[INFO] [13:10:23.578] Analysing ...\target\coverage-reports\jacoco-unit.exec
[INFO] [13:10:30.390] Sensor JaCoCoSensor done: 6875 ms
[INFO] [13:10:30.390] Sensor JaCoCoItSensor...
[INFO] [13:10:30.390] Analysing ...\target\coverage-reports\jacoco-it.exec
[INFO] [13:10:30.469] Sensor JaCoCoItSensor done: 79 ms
[INFO] [13:10:30.484] Sensor SurefireSensor...
[INFO] [13:10:30.484] parsing ...\target\surefire-reports
[INFO] [13:10:30.828] Sensor SurefireSensor done: 344 ms
[INFO] [13:10:30.828] Sensor CpdSensor...
[INFO] [13:10:30.828] SonarEngine is used …
Run Code Online (Sandbox Code Playgroud)

integration-testing code-coverage jacoco sonarqube

6
推荐指数
1
解决办法
8759
查看次数

Symfony2安全性:多个提供者

我的项目中有2个包:

  • SRC /韩国/ AlmacenBundle
  • SRC /加尔韦斯/ RepuestosBundle

每个都有自己的数据库

  • korea_motos - > AlmacenBundle
  • galvez_motos - > RepuestosBundle

实际上我的security.yml只有一个提供者:

providers:
    korea:
        entity: { class: Korea\AlmacenBundle\Entity\Usuario, property: username }
Run Code Online (Sandbox Code Playgroud)

如您所见,两个bundle都通过同一个表进行身份验证:Usuario,在korea_motos中

表:Usuario(korea_motos数据库)

--ID-- | ---- ---- USERNAME | ---------管束---

----- ----- 1 | -------------管理---------------- | ------- --- AlmacenBundle ----------

----- ----- 2 | -------------管理---------------- | ------- --- RepuestosBundle -------

现在我想验证用户,对于RepuestosBundle,在galvez_motos中使用表Usuario,删除上一表中的"bundle"列.

问题出在security.yml文件中.如果我这样做:

providers:
    korea:
        entity: { class: Korea\AlmacenBundle\Entity\Usuario, property: username }
    galvez:
        entity: { class: Galvez\RepuestosBundle\Entity\Usuario, property: username }
Run Code Online (Sandbox Code Playgroud)

Symfony发布了一个例外:

The class 'Galvez\RepuestosBundle\Entity\Usuario' was not …
Run Code Online (Sandbox Code Playgroud)

symfony symfony-security

6
推荐指数
2
解决办法
5334
查看次数

SonarQube 规则鱿鱼:S1451 应定义版权和许可证标头

我的所有 SonarQube 代码分析 Java 项目都未能遵循此规则。

每个源文件都应以标头开头,说明文件所有权以及分发应用程序必须使用的许可证。此规则必须包含每个文件开头所需的标题文本。

有一个参数:

headerFormat 预期的版权和许可标头(纯文本)

但没有关于如何配置的示例。默认情况下 headerFormat 为空,我找不到有关配置此规则的文档。

我猜应该有某种可以使用的正则表达式或模板语言?

sonarqube sonarqube5.1

6
推荐指数
1
解决办法
1万
查看次数

是否有任何Jenkins API可以获取工件名称并下载它?

我想问一下,如果我使用詹金斯.如何获取所有工件列表并下载它,但不能从jenkins Web界面获取.我想为某些目标制作自己的网络界面.

有没有jenkins API可以做到这一点?

api download artifact jenkins jenkins-api

6
推荐指数
2
解决办法
9818
查看次数

订阅者不应因可观察的错误而停止

我正在为一个订阅者苦苦挣扎,它会在出错时自动取消订阅:

observable
  .subscribe(
    (data) => {
      // some logic encountering an error during execution
      // comparable to throw new Error()
    }
  )
Run Code Online (Sandbox Code Playgroud)

我可以通过使用 try / catch 来防止它:

observable
  .subscribe(
    (data) => try { 
        // some logic encountering an error during execution
        // comparable to throw new Error()
      } catch(e) {
      }
  )
Run Code Online (Sandbox Code Playgroud)

但这感觉像是一种解决方法。

我已经深入研究了 Subscriber 和 SafeSubscriber 的来源,它们会在出错时自动调用取消订阅:

  private __tryOrUnsub(fn: Function, value?: any): void {
    try {
      fn.call(this._context, value);
    } catch (err) {
      this.unsubscribe();
      throw err;
    }
  }
Run Code Online (Sandbox Code Playgroud)

实现自己的订阅者或使用 try/catch …

rxjs typescript

6
推荐指数
1
解决办法
2989
查看次数

什么是common.chunk.js?

我有一个Angular 5应用程序,运行angular-cli 1.6.6,当捆绑我的应用程序时,我(在所有其他人中)有一个common.chunk.js.

你知道这是什么吗?它与我的任何模块都不匹配,它也不是供应商主要polyfill,因为它们有专用的块.

在此输入图像描述

webpack angular-cli angular

6
推荐指数
2
解决办法
8003
查看次数

如何更改插件和功能文件名中的限定符

我正在尝试重命名 eclipse-repository 模块的存储库文件夹中的工件。目前它们是自动生成的,例如...1.0.0.v20130315-1927.jar

我还没有找到任何有效的配置参数。我尝试在配置中使用限定符设置(请参阅tycho-p2-repository-plugin),但它不起作用。

<?xml version="1.0" encoding="UTF-8"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>development.statTool</groupId>
        <artifactId>Application</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <groupId>development.statTool</groupId>
    <artifactId>development.statTool.p2</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>eclipse-repository</packaging>

    <properties>
        <tycho-version>0.16.0</tycho-version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-p2-repository-plugin</artifactId>
                <version>${tycho-version}</version>

                <configuration>
                    <qualifier>abcd</qualifier>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
Run Code Online (Sandbox Code Playgroud)

p2 tycho

5
推荐指数
1
解决办法
1936
查看次数

如何从路由文件中发出socket.io中的事件?

这是我的应用配置

app.js

//SERVER
var server = app.listen(3000, function(){
    console.log("Express server listening on port %d in %s mode", app.get('port'),
    app.settings.env);
});
//SOCKET.IO
var io = require('./socket.io').listen(server)
Run Code Online (Sandbox Code Playgroud)

/ socketio

var socketio = require('socket.io')

module.exports.listen = function(app)
{
    io = socketio.listen(app);
    io.configure('development',function()
    {
            //io.set('transports', ['websocket', 'xhr-polling']);
            //io.enable('log');
    });
    io.configure('production',function()
    {
        io.enable('browser client minification');  // send minified client
        io.enable('browser client etag');          // apply etag caching logic based on version number
        io.set('log level', 1);                    // reduce logging
        io.set('transports', [                     // enable all transports (optional if …
Run Code Online (Sandbox Code Playgroud)

javascript node.js express socket.io

5
推荐指数
1
解决办法
1357
查看次数