2015-07-01 206 views
0

工作我試圖做一個捆綁安裝的JRuby(Windows)和我收到此錯誤:JRuby的捆綁安裝不寶石「scrypt」

C:/jruby-1.7.19/bin/jruby.exe -rubygems C:/jruby-1.7.19/lib/ruby/gems/shared/gems/rake-10.1.0/bin/rake RUBYARCHDIR=C:/jruby-1.7.19/lib/ruby/gems/shared/extensions/universal-java-1.8/1.9/scrypt-2.0.2 RUBYLIBDIR=C:/jruby-1.7.19/lib/ruby/gems/shared/extensions/universal-java-1.8/1.9/scrypt-2.0.2 
io/console not supported; tty will not be manipulated 
mkdir -p i386-windows 
cc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -msse -msse2 -fPIC -o i386-windows/crypto_scrypt-sse.o -c ./crypto_scrypt-sse.c 
rake aborted! 
Command failed with status (127): [cc -fexceptions -O -fno-omit-frame-pointer...] 
org/jruby/RubyProc.java:271:in `call' 
org/jruby/RubyProc.java:271:in `call' 
org/jruby/RubyArray.java:1613:in `each' 
org/jruby/RubyArray.java:1613:in `each' 
org/jruby/RubyArray.java:1613:in `each' 
org/jruby/RubyArray.java:1613:in `each' 
Tasks: TOP => default => i386-windows/scrypt_ext.dll => i386-windows/crypto_scrypt-sse.o 
(See full trace by running task with --trace) 

rake failed, uncaught signal 1 

我已經安裝了JRuby和JVM。

回答

0

你試圖安裝紅寶石的Java版本內原生擴展寶石:通常是一個糟糕的主意......

我發現在https://github.com/wg/scrypt scrypt算法的純Java實現。

您需要從Maven(http://search.maven.org/remotecontent?filepath=com/lambdaworks/scrypt/1.4.0/scrypt-1.4.0.jar)下載jar文件,將其添加到您的庫路徑或需要代碼中的jar。

接下來是編寫一個包裝來模仿scrypt行爲,將它用作ruby/rails代碼中的插入替換。

或者,您可以直接刪除scrypt位並使用java庫。下面是jirb(1.7.20)測試的一個片段:

>> require 'java' 
=> true 
>> require './scrypt-1.4.0.jar' 
=> true 
>> java_import 'com.lambdaworks.crypto.SCryptUtil' 
=> [Java::ComLambdaworksCrypto::SCryptUtil] 
>> passwd,n,r,p = 'secret',16384,8,1 
=> ["secret", 16384, 8, 1] 
>> hashed_passwd = SCryptUtil.scrypt(passwd,n,r,p) 
=> "$s0$e0801$MzcxaOBVz7kaVU6E5HV0cg==$RAx9ADWVeyZE5JRl+J1NpiBSEPNabEcVdR7drddpgMw=" 
>> SCryptUtil.check(passwd,hashed_passwd) 
=> true 
>> SCryptUtil.check('wrong password',hashed_passwd) 
=> false 
0

這是晚了,但我只是wrote一個多平臺gem它包裝起來的細節作爲API下拉更換爲scrypt gem

gem install scrypt-ruby -P MediumSecurity

相關問題