cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using libsodium in php on cPanel shared hosting?

I'm not an expert PHP developer, but I'm trying to use libsodium on Godaddy; however, the calls and constants seem to be undefined despite it showing up on phpinfo and me having previously enabled the module via PHP version.

 

Here's an example that doesn't work (bascially from libsodium's documentation):

 

<?php
var_dump(phpversion('libsodium')); // shows 1.0.7

// Generating your encryption key
$key = random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES);
echo $key."<br>";

// Using your key to encrypt information
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
echo $nonce."<br>";

$ciphertext = sodium_crypto_secretbox('test', $nonce, $key);
echo $ciphertext."<br>";
?>