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 8385741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:44:54+00:00 2026-06-09T17:44:54+00:00

i have created a module and it’s override magento hash function properly. But question

  • 0

i have created a module and it’s override magento hash function properly.
But question is, i want to check some conditions.

if admin login,
else if soap api user login ,
else if customer,
else if migration customer

My Question is , how we track which type request coming to getHash function?

<?php
class Namespace_ShaModule_Model_Encryption extends Mage_Core_Model_Encryption
{


    public function hashSHA($password){
        return sha1($password);

    }
    public function hashMD5($password){
        return md5($password);

    }
    public function noHash($password){
        return $password;

    }

    public function validateHash($password, $hash) {

        return $this->hash($password) === $hash;

        }

    public function getHash($password, $salt = false)
    {

          return $this->hash($password);
    }
    public function hash($data){

        if(admin_login_handling_and_api_user_accounts){

            return $this->hashMD5($password);

        } else if(Magento_customer_handling){

            return $this->hashSHA($password);

        }else if(soap_Api_customer_handling){

            return $this->noHash($password);

        }

    }



}
?>
  • 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. Editorial Team
    Editorial Team
    2026-06-09T17:44:55+00:00Added an answer on June 9, 2026 at 5:44 pm

    From my point of view, this action maynot be in Encryption class’s scope. The Encryption class should take the password as parameter and return as hashed password. So in order to implement your requirement, you may add an additional parameter to function getHash, like

    function getHash($password, $salt = false, $type = 'md5') {
      switch($type) {
        case 'md5':
          return $this->hashMD5($password, $salt);
        case 'sha1':
          ...
      }
    }
    

    And then a few investigation may be taken to insert to the core code or write an additional module to do this. For example, you may add the $type variable to the customer login and register process to make a change at the hash function. It may be quite exhausting to do digging into core file just like this. Moreover, it’s better for you to have a Encryption Factory to manage this or other design pattern issues.

    Another way is so tricky that I just write here as reference, but not recommend this. It is to use the function debug_backtrace() to check who call the getHash() function and determine the type inside the getHash() function. I don’t know the system requirements and resource usage when using such kind of function. It may be helpful to solve this problem but bare lots of deficits.

    Hope this is helpful to you 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a module that i want to collect some simple data in
i have created a module with this among others this function in it: <?php
I have created a simple Python module and want to distribute it with pip.
I have created a class called Class1, and in another module, I want to
I have created a module in Magento which takes certain views from customers about
I have created a module in access 2007 that will update linked tables, but
I have created a custom module and am using hook_block to programmatically create some
I have created some classes in a module, f.i. Request (app/models/api/request.rb) class Api::Request end
I have created a module that works on a vanilla installation of Drupal but
I have created a drupal module which displays some reporting data. I would like

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.