1

Is it possible to convert following php function which is using mcrypt standards to js using mcrypt lib.

function fnEncrypt($sValue, $sSecretKey)
    {
        return rtrim(
            base64_encode(
                mcrypt_encrypt(
                    MCRYPT_RIJNDAEL_256,
                    $sSecretKey, $sValue, 
                    MCRYPT_MODE_ECB, 
                    mcrypt_create_iv(
                        mcrypt_get_iv_size(
                            MCRYPT_RIJNDAEL_256, 
                            MCRYPT_MODE_ECB
                        ), 
                        MCRYPT_RAND)
                    )
                ), "\0"
            );
    }
Divyam Solanki
  • 461
  • 2
  • 7
  • 25
  • StackOverflow isn't a code conversion service. – Mike Dec 31 '16 at 02:20
  • @Mike - I suggest read the question, i asked 'is it possible'. Anyway thanks for suggestion – Divyam Solanki Dec 31 '16 at 03:08
  • This question seems way too localized. Even googling "mcrypt-js" with quotes I couldn't find the package on the first page (however there was one called "js-mcrypt"). I would suggest going through the functions above one-by-one and seeing if they exist in either pure JS or the library you mention. If they do, then the answer is "yes". If not, the answer is "no". Perhaps you might want to contact the developer if there is anything you believe is missing. You may want to switch to another library. Probably the hardest part would be generating crypographically secure random values. – Mike Jan 02 '17 at 18:42

0 Answers0