public function make_lincese($product_code, $name, $email) { ## NOTE ############################################### # If you change the parameters the function acepts do not # forget to change the lower string concatenation # to include all fields in the license generation $stringData = $product_code . "," . $name . "," . $email; ################################################# $binary_signature = ""; openssl_sign($stringData, $binary_signature, $this->private_key, OPENSSL_ALGO_DSS1); // base 32 encode the signature $encoded = base32_encode($binary_signature); // replace O with 8 and I with 9 $replacement = str_replace("O", "8", str_replace("I", "9", $encoded)); //remove padding if any. $padding = trim(str_replace("=", "", $replacement)); $dashed = rtrim(chunk_split($padding, 5, "-")); $theKey = substr($dashed, 0, strlen($dashed) - 1); return $theKey; }
public function make_lincese($product_code, $name, $email) { // Generae a sha1 digest with the passed parameters. $stringData = $product_code . "," . $name . "," . $email; echo "Data: " . $stringData . "<br>"; $binary_signature = ""; openssl_sign($stringData, $binary_signature, $this->private_key, OPENSSL_ALGO_DSS1); echo "Binary Sig: " . $binary_signature . "<br>"; // base 32 encode the stuff $encoded = base32_encode($binary_signature); echo "Original Key: " . $encoded . "<br>"; echo "Key Length: " . strlen($encoded) . "<br>"; // replace O with 8 and I with 9 $replacement = str_replace("O", "8", str_replace("I", "9", $encoded)); echo "Replaced: " . $replacement . "<br>"; //remove padding if any. $padding = trim(str_replace("=", "", $replacement)); echo "Stripped: " . $padding . "<br>"; $dashed = rtrim(chunk_split($padding, 5, "-")); $theKey = substr($dashed, 0, strlen($dashed) - 1); echo "Dashed: " . $theKey . "<br><br>"; echo "<strong>Verify the just created License<br></strong>"; $this->verify_license($product_code, $name, $email, $theKey); return $theKey; }
} // Get data $mOtp = new MultiOtpDb(OCP\Config::getAppValue('user_otp', 'EncryptionKey', 'DefaultCliEncryptionKey')); $mOtp->EnableVerboseLog(); //$mOtp->SetDisplayLogOption(1); if ($_POST && $_POST["otp_action"] === "delete_otp" && $mOtp->CheckUserExists($uid)) { if ($mOtp->DeleteUser($uid)) { OCP\JSON::success(array("data" => array("message" => $l->t("OTP Changed")))); } else { OCP\JSON::error(array("data" => array("message" => $l->t("check apps folder rights")))); } } else { if ($_POST && $_POST["otp_action"] === "send_email_otp" && $mOtp->CheckUserExists($uid)) { $mOtp->SetUser($uid); if (OCP\Config::getAppValue('user_otp', 'TokenBase32Encode', true)) { $UserTokenSeed = base32_encode(hex2bin($mOtp->GetUserTokenSeed())); //$tmpl->assign('TokenBase32Encode',true); } else { $UserTokenSeed = hex2bin($mOtp->GetUserTokenSeed()); } $key = 'email'; $mail = ""; $query = OC_DB::prepare('SELECT `configvalue` FROM `*PREFIX*preferences` WHERE `configkey` = ? AND `userid`=?'); $result = $query->execute(array($key, $uid)); if (!OC_DB::isError($result)) { $row = $result->fetchRow(); $mail = $row['configvalue']; } $txtmsg = '<html><p>Hi, ' . $uid . ', <br><br>'; $txtmsg .= '<p>find your OTP Configuration<br>'; $txtmsg .= 'User Algorithm : ' . $mOtp->GetUserAlgorithm() . '<br>';
/** * @fn encode($txt) * @short Encodes a string with Base32 encoding * @param txt The string to encode */ public static function encode($txt) { return base32_encode($txt); }
} } else { $torrenttpl->set("ornuk", false, TRUE); $torrenttpl->set("or", false, TRUE); } //pretime orlydb end if (!empty($row["comment"])) { $row["description"] = format_comment($row["comment"]); } if (isset($row["cat_name"])) { $row["cat_name"] = unesc($row["cat_name"]); } else { $row["cat_name"] = unesc($language["NONE"]); } if ($btit_settings["magnet"] == true) { $row["magnet"] = "<a href=magnet:?xt=urn:btih:" . strtoupper(base32_encode(pack('H*', $row["info_hash"]))) . ">" . image_or_link("images/magnet.png", "", "Magnet") . "</a>"; $torrenttpl->set("MAGNET", true, true); } else { $torrenttpl->set("MAGNET", false, true); } require 'ajaxstarrater/_drawrating.php'; # ajax rating if ($row["username"] != $CURUSER["username"] && $CURUSER["uid"] > 1) { $row["rating"] = rating_bar("" . $_GET["id"] . "", 5); } else { $row["rating"] = rating_bar("" . $_GET["id"] . "", 5, 'static'); } $row["rating"]; $row["size"] = makesize($row["size"]); // files in torrent - by Lupin 20/10/05 if ($btit_settings["smf_autotopic"] == "true") {
public function testEncodeDecode() { $string = url_base64_encode("1234567890"); $this->assertTrue($string === "MTIzNDU2Nzg5MA"); // $string = url_base64_decode($string); $this->assertTrue($string === "1234567890"); // $key = '111'; $one = xencrypt("1234567890", $key); $two = xencrypt("1234567890", $key); $this->assertTrue($one and $two and $one != $two); $this->assertTrue(xdecrypt($one, $key) === "1234567890"); $this->assertTrue(xdecrypt($two, $key) === "1234567890"); $this->assertTrue(!xdecrypt($two, $key . '1')); // $string = base32_encode("1234567890"); $this->assertTrue(!!preg_match('~^[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]+$~', $string)); // $string = base32_decode($string); $this->assertTrue($string === "1234567890"); // $key = '111'; $one = oencrypt("1234567890", $key); $two = oencrypt("1234567890", $key); $this->assertTrue($one and $two and $one != $two); $this->assertTrue(odecrypt($one, $key) === "1234567890"); $this->assertTrue(odecrypt($two, $key) === "1234567890"); $this->assertTrue(!odecrypt($two, $key . '1')); }
//~ $mOtp->SetUsersFolder( //~ OCP\Config::getAppValue( //~ 'user_otp','UsersFolder', //~ getcwd()."/apps/user_otp/3rdparty/multiotp/users/" //~ ) //~ ); $tmpl = new OCP\Template('user_otp', 'personalSettings'); $tmpl->assign('disableDeleteOtpForUsers', OCP\Config::getAppValue('user_otp', 'disableDeleteOtpForUsers', '0')); if ($mOtp->CheckUserExists(OCP\User::getUser())) { $tmpl->assign('UserExists', true); $mOtp->SetUser(OCP\User::getUser()); $img = \OCP\Util::linkToRoute('user_otp_qrcode'); $tmpl->assign('UserTokenUrlLink', $mOtp->GetUserTokenUrlLink()); $tmpl->assign('UserTokenQrCode', $img); //~ if(OCP\Config::getAppValue('user_otp','TokenBase32Encode',true)){ //~ $tmpl->assign('UserTokenSeed',base32_encode(hex2bin($mOtp->GetUserTokenSeed()))); //~ $tmpl->assign('TokenBase32Encode',true); //~ }else{ //~ $tmpl->assign('UserTokenSeed',hex2bin($mOtp->GetUserTokenSeed())); //~ } $tmpl->assign('UserTokenSeed', base32_encode(hex2bin($mOtp->GetUserTokenSeed()))); $tmpl->assign('UserPin', $mOtp->GetUserPin()); $tmpl->assign('UserPrefixPin', $mOtp->GetUserPrefixPin()); $tmpl->assign('UserLocked', $mOtp->GetUserLocked()); $tmpl->assign('UserAlgorithm', $mOtp->GetUserAlgorithm()); $tmpl->assign('UserTokenTimeIntervalOrLastEvent', strtolower($mOtp->GetUserAlgorithm()) === 'htop' ? $mOtp->GetUserTokenLastEvent() : $mOtp->GetUserTokenTimeInterval()); } else { $tmpl->assign('UserExists', false); $tmpl->assign('UserPrefixPin', OCP\Config::getAppValue('user_otp', 'UserPrefixPin', '0')); } return $tmpl->fetchPage();
<?php $all32 = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V"); function base32_encode($int) { $d1 = 0; $d2 = 0; $d3 = 0; $d4 = 0; $i = 0; global $all32; while ($i < $int) { $d4++; if ($d4 == 31) { $d4 = 0; $d3++; } if ($d3 == 31) { $d3 = 0; $d2++; } if ($d2 == 31) { $d2 = 0; $d1++; } $i++; } echo $all32[$d1] . $all32[$d2] . $all32[$d3] . $all32[$d4]; } base32_encode(95299);
public static function repoEncodeWeb($repo) { return base32_encode(\Dcrypt\Aes::encrypt($repo, self::key . \Session::getId() . self::githubId())); }
$torrents[$i]["dt"] = $cleandate; } /** Prevent that "torrents added..." wont appear again with the same date **/ $prevdate = $thisdate; $man = array('Jan' => 'January', 'Feb' => 'February', 'Mar' => 'March', 'Apr' => 'April', 'May' => 'May', 'Jun' => 'June', 'Jul' => 'July', 'Aug' => 'August', 'Sep' => 'September', 'Oct' => 'October', 'Nov' => 'November', 'Dec' => 'December'); foreach ($man as $eng => $ger) { $cleandate = str_replace($eng, $ger, $cleandate); } $dag = array('Mon' => 'Monday', 'Tues' => 'Tuesday', 'Wednes' => 'Wednesday', 'Thurs' => 'Thursday', 'Fri' => 'Friday', 'Satur' => 'Saturday', 'Sun' => 'Sunday'); foreach ($dag as $eng => $ger) { $cleandate = str_replace($eng . 'day', $ger . '', $cleandate); } } // Split torrents by hasu if ($btit_settings["magnet"] == true) { $torrents[$i]["magnet"] = " <td align=\"center\" width=\"20\" class=\"lista\" style=\"text-align: center; background:{$dttd}\"><a href=magnet:?xt=urn:btih:" . strtoupper(base32_encode(pack('H*', $data["hash"]))) . ">" . image_or_link("images/magnet.png", "", "Magnet Link") . "</a></td>"; } // progress if ($data["external"] == "yes") { $prgsf = $language["NA"]; } else { $id = $data['hash']; if ($XBTT_USE) { $subres = get_result("SELECT sum(IFNULL(xfu.left,0)) as to_go, count(xfu.uid) as numpeers FROM xbt_files_users xfu INNER JOIN xbt_files xf ON xf.fid=xfu.fid WHERE xf.info_hash=UNHEX('{$id}') AND xfu.active=1", true, $btit_settings['cache_duration']); } else { $subres = get_result("SELECT sum(IFNULL(bytes,0)) as to_go, count(*) as numpeers FROM {$TABLE_PREFIX}peers where infohash='{$id}'", true, $btit_settings['cache_duration']); } $subres2 = get_result("SELECT size FROM {$TABLE_PREFIX}files WHERE info_hash ='{$id}'", true, $btit_settings['cache_duration']); $torrent = $subres2[0]; $subrow = $subres[0]; $tmp = 0 + $subrow["numpeers"];