sha1

  • We use the Digest::SHA1 class to build the equivalent cryptographic hash to PHP’s sha1 function. This works the same as the Digest::MD5 class mentioned in md5, and needs to require the Digest library using require "digest".

    PHP

    print sha1("my string");
    // => e19343e6c6c76f8f634a685eba7c0880648b1389

    Ruby

    require "digest"
     
    print Digest::SHA1.hexdigest("my string")
    # => e19343e6c6c76f8f634a685eba7c0880648b1389

    see also

rtrim sha1_file

Looking for Rails or PHP web application development, integration, and training?

Rails for PHP is brought to you by Maintainable Software. Get custom web applications and personalized training from the authors of the book and website.