0

I have a very small ruby script that I need to run in scala either by straightway running the sript which according to resources online is possible through org.jruby but the dependency doesn't work for me in build.sbt or by writing the same logic in scala but I am not able to get the logic correct for Ruby's ActiveSupport encryptor. The intention is to create a scala web api which folks can utilize to retrive the passwords based on inputs. Thanks in advance. Following is the script that I need to run:



# Usage: ./gen_password.rb SECRET ID URL
# Example: ./gen_password.rb 73191239133f 1234567 myshop.com
# Note: 73191239133f is a fake secret. It will not work.


require "active_support/all"


SECRET = ARGV[0]
ID = ARGV[1]
URL = ARGV[2]


encryptor = ActiveSupport::MessageEncryptor.new(SECRET)

puts("#{ID}+#{URL}+#{Time.now.utc.to_i}")
puts encryptor.encrypt_and_sign("#{ID}+#{URL}+#{Time.now.utc.to_i}")

4
  • 2
    I would just google the Java encryption packages, you don't have anything too complex there. Commented Feb 4, 2024 at 21:29
  • 1
    If you could share your attempt at re-implementing this in Scala and what error it causes, it would be easier for the community to help you fix whatever is preventing you from getting the logic right. Commented Feb 5, 2024 at 10:35
  • Sure let me share the scala implementation Commented Feb 5, 2024 at 16:09
  • Rails 4 for real or is that a mistag? Commented Feb 9, 2024 at 15:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.