This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class UrlShortener{ | |
private static $base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';//the real base should not be easy to guess | |
private static $len = 5; | |
private $salt = 0; //simple salt strategy - just shift the base | |
public function __construct($salt = 0){ | |
$this->salt = $salt; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertPKCS1toPKCS8($pkcs1){ | |
$start_key = $pkcs1; | |
$start_key = str_replace('-----BEGIN RSA PUBLIC KEY-----', '', $start_key); | |
$start_key = trim(str_replace('-----END RSA PUBLIC KEY-----', '', $start_key)); | |
$key = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A' . str_replace("\n", '', $start_key); | |
$key = "-----BEGIN PUBLIC KEY-----\n" . wordwrap($key, 64, "\n", true) . "\n-----END PUBLIC KEY-----"; | |
return $key; | |
} |