Skip to content

Instantly share code, notes, and snippets.

/* POLYCRYPT HASH */
function polycryptHash(){
document.getElementById("polypassword").innerHTML=password;
var polystring=util.str2abv(password);
var op=window.polycrypt.digest("SHA-256",polystring);
op.oncomplete=function(e){
var hex=util.abv2hex(e.target.result);
document.getElementById("polyhash").innerHTML=hex;
}
op.onerror=function(e){
rsa = RSA.load_pub_key("mykey.pub")
ctxt = rsa.public_encrypt(secretstring, RSA.pkcs1_padding)
encryptedText = ctxt.encode('base64')
print 'Encrypted Text = '+encryptedText
priv = RSA.load_key("mykey.pem")
decodeEncryptedText = encryptedText.decode('base64')
decryptedText = priv.private_decrypt(decodeEncryptedText, RSA.pkcs1_padding)
print 'Decrypted Text = '+decryptedText
function public_encrypt($plaintext){
$fp=fopen("./mykey.pub","r");
$pub_key=fread($fp,8192);
fclose($fp);
openssl_get_publickey($pub_key);
openssl_public_encrypt($plaintext,$crypttext, $pub_key );
return(base64_encode($crypttext));
}
function private_decrypt($encryptedext){
@glynrob
glynrob / gist:7059316
Created October 19, 2013 18:03
Python hashing example
md5 = hashlib.md5()
md5.update(password+saltstring)
print 'MD5 = '+md5.hexdigest()
sha1string = hashlib.sha1(password + saltstring)
print 'SHA1 = '+sha1string.hexdigest()
sha1string = hashlib.sha512(password + saltstring)
print 'SHA512 = '+sha1string.hexdigest()
@glynrob
glynrob / gist:7059295
Created October 19, 2013 18:01
Hashing in PHP
$md5 = md5($password.$salt);
echo "MD5 = $md5<br />";
$sha1 = sha1($password.$salt);
echo "SHA1 = $sha1<br />";
$sha512 = hash('sha512', $password.$salt);
echo "SHA512 = $sha512<br />";
<script id="centralTemplate" type="text/x-handlebars-template">
<div class="central">{{contentSent}}</div>
</script>
{{#unless contentSent.license}}
<h3>WARNING: license not set</h3>
{{/unless}}
{{#if contentSent.author}}
<p>{{contentSent.author.firstName}} {{contentSent.author.lastName}}</p>
{{else}}
<p>Unknown Author</p>
{{/if}}
{{#each contentSent.people}}
<li>{{@index}} - {{this}}</li>
{{else}}
<li>No people to list</li>
{{/each}}
{{#with contentSent.author}}
<p>By {{firstName}} {{lastName}}</p>
{{/with}}