Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
uphp:functions:aes_encrypt [2019/08/16 06:41]
admin
uphp:functions:aes_encrypt [2019/08/16 08:25] (current)
admin
Line 76: Line 76:
   $base64_decrypted = base64_decode($base64_encrypted);​   $base64_decrypted = base64_decode($base64_encrypted);​
   ​   ​
-  // we will use the calculated length from the encryption ​as the strlen() function +  // we will calculated ​the length from the base64 string rather than the encrypted  
-  // may not yield a valid result if the encrypted string has a zero in it.+  // one as the strlen() function may not yield a valid result if the encrypted string ​ 
 +  // has a zero in it.  As base64 is 6 bits and our data is 8, we just need to multiply  
 +  // the the length by 6/8 or 0.75 to get the base64-decoded size. 
 +   
 +  $len = intval(strlen($base64_encrypted) * 0.75);
   ​   ​
   // decryption ​ routine   // decryption ​ routine