Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 122965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:12:43+00:00 2026-05-11T04:12:43+00:00

I have a large database of users (~200,000) that I’m transferring from a ASP.NET

  • 0

I have a large database of users (~200,000) that I’m transferring from a ASP.NET application to a Ruby on Rails application. I don’t really want to ask every user to reset their password and so I’m trying to re-implement the C# password hashing function in Ruby.

The old function is this:

public string EncodePassword(string pass, string saltBase64)  {      byte[] bytes = Encoding.Unicode.GetBytes(pass);      byte[] src = Convert.FromBase64String(saltBase64);      byte[] dst = new byte[src.Length + bytes.Length];      Buffer.BlockCopy(src, 0, dst, 0, src.Length);      Buffer.BlockCopy(bytes, 0, dst, src.Length, bytes.Length);      HashAlgorithm algorithm = HashAlgorithm.Create('SHA1');      byte[] inArray = algorithm.ComputeHash(dst);      return Convert.ToBase64String(inArray);  } 

An example hashed password and salt is (and the password used was ‘password’):

Hashed password: ‘weEWx4rhyPtd3kec7usysxf7kpk=’ Salt: ‘1ptFxHq7ALe7yXIQDdzQ9Q==’ Password: ‘password’

Now with the following Ruby code:

require 'base64' require 'digest/sha1'   password = 'password' salt = '1ptFxHq7ALe7yXIQDdzQ9Q=='  concat = salt+password  sha1 = Digest::SHA1.digest(concat)  encoded = Base64.encode64(sha1)  puts encoded 

I’m not getting the correct password hash (I’m getting ‘+BsdIOBN/Vh2U7qWG4e+O13h3iQ=’ instead of ‘weEWx4rhyPtd3kec7usysxf7kpk=’). Can anyone see what the problem might be?

Many thanks

Arfon

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T04:12:44+00:00Added an answer on May 11, 2026 at 4:12 am

    Just a quick update, a colleague of mine has solved this:

    require 'base64' require 'digest' require 'jcode'   def encode_password(password, salt)  bytes = ''  password.each_char { |c| bytes += c + '\x00' }  salty = Base64.decode64(salt)  concat = salty+bytes  sha1 = Digest::SHA1.digest(concat)  encoded = Base64.encode64(sha1).strip()  puts encoded end 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's what I'm trying to do. I have an extremely large list of items.
I've got a large database, quite rapidly expanding and I've got a number of
I'm looking into creating an Web or iPad application that will use HTML5. After
I've got a web application with an NHibernate Data Access Layer. I have a
I am a beginner at database design and I would like to create a
Can you advise on whether I can use just the Query functionality from Lucene
I used Ryan Bates' populator gem along with the faker gem to populate my
Ok for sure this has been asked and answered already but i somehow can't
I'm currently working on a medium-sized web project, and I've ran into a problem.
I've been looking at ranking algorithms recently, specifically those used by Reddit and Hacker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.