小编Yag*_*giz的帖子

在BouncyCastle上使用数字签名算法(ECDSA)实现的椭圆曲线

我正在尝试实现ECDSA(椭圆曲线数字签名算法),但我在Java中找不到任何使用Bouncy Castle的例子.我创建了密钥,但我真的不知道我应该使用什么样的函数来创建签名并验证它.

public static KeyPair GenerateKeys()
    throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException
{
    ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("B-571");
    KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC");
    g.initialize(ecSpec, new SecureRandom());
    return g.generateKeyPair();
}
Run Code Online (Sandbox Code Playgroud)

java cryptography bouncycastle

8
推荐指数
2
解决办法
2万
查看次数

合并socket.io和express.js会话

我想将express.js和socket.io会话合并在一起.下面是我的代码(socket.io部分)

var io = require('socket.io').listen(app);
io.set('log level', 1);

io.sockets.on('connection', function (socket) {
    console.log('client connected');
client.send(client.id);//send client id to client itself
socket.on('connect', function(){
    console.log(socket.id + ' connected');
});
socket.on('disconnect', function(){
    console.log(socket.id + ' disconnected');
});
});
Run Code Online (Sandbox Code Playgroud)

我的express.js会话设置:

app.configure(function() {
  //app.use(express.logger());
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.static(__dirname + '/static'));
  app.use(express.cookieParser());
  app.use(express.session({store: MemStore({
    reapInterval: 60000 * 10
  }), secret:'foobar', key: 'express.sid'
}));
Run Code Online (Sandbox Code Playgroud)

我的主要问题是在我的终端中,当用户从一个网址移动到另一个网址时,会话ID也会发生变化:但我不希望它被更改.

info  - socket.io started
client connected
client connected
4Z0bYHzfWCEFzbbe4WUK disconnected
e_uSvxhSLbLAC9-F4WUL disconnected
client connected
bKDy90gsrWWTRJDD4WUM disconnected
client connected
RJ5qqCL2wfmXbd7U4WUN disconnected
client connected
wjN5Sqx4rucRtWL_4WUO …
Run Code Online (Sandbox Code Playgroud)

javascript session express socket.io

7
推荐指数
1
解决办法
2338
查看次数

具有日期的猫鼬或操作员

我正在尝试编写一个类似的查询:

var query = {
    userId: req.params.userId,
    isActive: true,
    'interval.start': {
        $lte: now
    },
    'interval.end': {
        $or: [
            { $gte: now },
            { $exists: false },
            { $eq: null } 
        ]
    }
};
Run Code Online (Sandbox Code Playgroud)

我想要实现的是我想找到适合这些条件的列:

  • interval.end日期应该大于现在.
  • 或结束日期不应存在
  • 或者它应该存在为null.

我得到了:Can't use $or with Date.错误.

谢谢.

mongoose mongodb node.js

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

Rails Jquery不适用于其他页面

我相信jQuery不能在你刚刚安装的页面上工作.例如,当我键入localhost:3000 /时,在'/'目录中所有jQuery都可以工作.但是当我点击Rails创建的链接时

<%= link_to "Example Link", news_path %>
Run Code Online (Sandbox Code Playgroud)

页面正确加载,但jQuery不起作用.我的jQuery代码如下所述:

$(function() {
  console.log( "pageloaded" );
  ....
  $('.up').click(function(){
    .....
  });
});
Run Code Online (Sandbox Code Playgroud)

javascript jquery ruby-on-rails ruby-on-rails-4

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

列表操作导致无限循环

我试图在Ionic Framework中创建一个用于列表目的的数组,并检查所有callcenter名称的第一个char,将它们添加到字母数组中.

  for (var i = 0; i < callcenterList.length; i++) {
    var value = callcenterList[i]._owner && callcenterList[i]._owner.company.name[0];

    if ((alphabet.indexOf(value) == -1 && isNaN(parseInt(value))) ||
      (isNaN(alphabet[0]) && !isNaN(value))) {
      if(!isNaN(value))
        value = 123;

      alphabet.push(value);

      callcenterList.splice(i, 0, {
        divider: {
          alphabet: value
        }
      });
    }
  };
Run Code Online (Sandbox Code Playgroud)

更换value = 123value = '#'的原因谷歌浏览器和谷歌Chrome金丝雀发生故障,并立即在Mac上使用最多的RAM 100%.

这是一个Javascript错误还是与Google Chrome本身有关?

javascript arrays infinite-loop

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

BouncyCastle ECDH密钥协议失败

我使用BouncyCastle API实现了Elliptic Curve Diffie Hellman加密.但是,关键协议似乎并没有正常运作.它打印错误.

我哪里做错了?谢谢.

ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("B-571");

    KeyPairGenerator g = KeyPairGenerator.getInstance("ECDH", "BC");

    g.initialize(ecSpec, new SecureRandom());

    KeyPair aKeyPair = g.generateKeyPair();

    KeyAgreement aKeyAgree = KeyAgreement.getInstance("ECDH", "BC");

    aKeyAgree.init(aKeyPair.getPrivate());

     KeyPair bKeyPair = g.generateKeyPair();

    KeyAgreement bKeyAgree = KeyAgreement.getInstance("ECDH", "BC");

    bKeyAgree.init(bKeyPair.getPrivate());

    //
    // agreement
    //
    aKeyAgree.doPhase(bKeyPair.getPublic(), true);
    bKeyAgree.doPhase(aKeyPair.getPublic(), true);

    byte[] aSecret = aKeyAgree.generateSecret();
    byte[] bSecret = bKeyAgree.generateSecret();

    System.out.println(aSecret);
    System.out.println(bSecret);
    if (aSecret.equals(bSecret)){
        return true;
    } else { return false; }
Run Code Online (Sandbox Code Playgroud)

java bouncycastle

4
推荐指数
1
解决办法
4080
查看次数

使用Google API仅使用访问令牌发送电子邮件

我想通过Google API发送电子邮件,而不需要不必要的OAUTH2参数.我只有该用户的access_token和refresh_token.

如何使用Request npm插件通过NodeJS中的基本POST请求通过Gmail API发送电子邮件?

google-api node.js google-api-nodejs-client gmail-api

4
推荐指数
1
解决办法
3499
查看次数

eclipse android编程XML文件中的错误:中止构建

我正在创建一个Android应用程序,一个简单的计算器,但我得到一个XML文件中的"[2012-03-12 20:22:21 - 计算器]错误:中止构建." 这是我无法解决的.你能找出问题吗?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout 
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<EditText
    android:id="@+id/txtResult"
    android:layout_width="fill_parent"
    android:layout_height="54dp"
    android:inputType="number"
    android:singleLine="true"
    android:text="@string/result"
    android:editable="false" 
    android:gravity="right">
</EditText>

</LinearLayout>
<LinearLayout 
android:id="@+id/linearLayout3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

 <Button
     android:id="@+id/button1"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_weight="1.25"
     android:text="@string/number1" />

 <Button
     android:id="@+id/button2"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_weight="1.25"
     android:text="@string/number2" />

 <Button
     android:id="@+id/button3"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="@string/number3"
     android:layout_weight="1.25" />

 <Button
     android:id="@+id/buttonPlus"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_weight="1.25"
     android:text="@string/calcAddition" />

</LinearLayout>
 <LinearLayout 
android:id="@+id/linearLayout4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

     <Button
         android:id="@+id/button4"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="@string/number4"
         android:layout_weight="1.25" />

     <Button
         android:id="@+id/button5"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

java eclipse android

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

Rails has_many belongs_to association

我是Rails的新手,基本上和其他人一样,在我的脑海中也有同样的问题.我想将两个表相互链接.但我不能这样做.帮助我强大的stackoverflow用户.

用户类:

class User < ActiveRecord::Base
  attr_accessible :password, :username, :oauth_token, :provider, :uid, :oauth_expires_at, :picture, :email, :name, :location, :gender, :updated_at, :is_admin
  has_many :posts   
end
Run Code Online (Sandbox Code Playgroud)

帖子课:

class Post < ActiveRecord::Base
  attr_accessible :details, :title, :user_id, :picture
  belongs_to :user
end
Run Code Online (Sandbox Code Playgroud)

在终端中,我登录到rails控制台并说:

@allusers = Users.all
@allposts = Users.Posts.all
Run Code Online (Sandbox Code Playgroud)

它给出了错误,有没有其他方法或Ruby代码链接这些表?

ruby-on-rails

0
推荐指数
1
解决办法
169
查看次数

电子默认应用程序不会更改

我正在尝试将我的Google Closure Library使用的网络应用程序转换为Electron.我曾经grunt-electron打包过应用程序,但它似乎并没有改变Test.app的默认应用程序.在Test.app/Contents/Contents/app/中存在我的应用程序,但它不加载我的应用程序,但确实加载默认应用程序.

我的档案层次:

  • www:index.js(电子配置文件),index.html,css/,fonts /,js/**

我的笨蛋任务:

electron: {
        osxBuild: {
            options: {
                name: 'Test App',
                dir: 'www',
                out: 'build',
                version: '0.25.3',
                platform: 'darwin',
                arch: 'x64'
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

gruntjs electron

0
推荐指数
1
解决办法
342
查看次数