+ openssl_public_encrypt($v, $ciphertext, $pub_key);
+ return $ciphertext;
+ }
+
+ function decrypt($v)
+ {
+ $key_dir = "{$this->getKeyDirectory()}/pri.key";
+
+ if(!file_exists($key_dir)) {
+ print_r("Cannot find {$key_dir}");
+ exit;
+ }
+
+ $pri_key = file_get_contents($key_dir);
+ if(!$pri_key) {
+ return;
+ }
+
+ openssl_private_decrypt($v, $plaintext, $pri_key);
+ return $plaintext;
+ }
+
+ function checkWritable($cls_name,$func_name,$dir)
+ {
+ if(!is_writable($dir)) {
+ print_r("Cannot run {$cls_name} :: {$func_name}\n");
+ print_r("Directory: {$dir} is not writable by current user\n");
+ exit;
+ }
+
+ return true;