Skip to content

Commit

Permalink
import bricks from js-hash
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Dec 21, 2014
1 parent f1aace4 commit a90f38e
Show file tree
Hide file tree
Showing 12 changed files with 181 additions and 9 deletions.
97 changes: 96 additions & 1 deletion js/dist/uint64.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,101 @@
'use strict';


/* js/src/dummy.js */
/* js/src/add64.js */

var add64 = function ( a , b ) {

var t , u , c ;

t = ( a[1] >>> 0 ) + ( b[1] >>> 0 ) ;
u = t & 0xffffffff ;
c = +( t > 0xffffffff ) ;

return [ ( a[0] + b[0] + c ) & 0xffffffff , u ] ;

} ;

exports.add64 = add64 ;

/* js/src/and64.js */

var and64 = function ( a , b ) {

return [ a[0] & b[0] , a[1] & b[1] ] ;

} ;

exports.and64 = and64 ;

/* js/src/big64.js */

var big64 = function ( a , o ) {

return [
( a[o + 0] << 24 ) | ( a[o + 1] << 16 ) | ( a[o + 2] << 8 ) | a[o + 3] ,
( a[o + 4] << 24 ) | ( a[o + 5] << 16 ) | ( a[o + 6] << 8 ) | a[o + 7]
] ;

} ;

exports.big64 = big64 ;

/* js/src/not64.js */

var not64 = function ( a ) {

return [ ~a[0] , ~a[1] ] ;

} ;

exports.not64 = not64 ;

/* js/src/rot64.js */

var rot64 = function ( a , s ) {

if ( s < 32 ) {

return [
( a[1] << ( 32 - s ) ) | ( a[0] >>> s ) ,
( a[0] << ( 32 - s ) ) | ( a[1] >>> s )
] ;

}

else {

s -= 32 ;

return [
( a[0] << ( 32 - s ) ) | ( a[1] >>> s ) ,
( a[1] << ( 32 - s ) ) | ( a[0] >>> s )
] ;

}

} ;

exports.rot64 = rot64 ;

/* js/src/shr64.js */

var shr64 = function ( a , s ) {

return [ a[0] >>> s , ( a[0] << ( 32 - s ) ) | ( a[1] >>> s ) ] ;

} ;

exports.shr64 = shr64 ;

/* js/src/xor64.js */

var xor64 = function ( a , b ) {

return [ a[0] ^ b[0] , a[1] ^ b[1] ] ;

} ;

exports.xor64 = xor64 ;

})(typeof exports === 'undefined' ? this['uint64'] = {} : exports);
2 changes: 1 addition & 1 deletion js/dist/uint64.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/dist/uint64.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions js/src/add64.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

var add64 = function ( a , b ) {

var t , u , c ;

t = ( a[1] >>> 0 ) + ( b[1] >>> 0 ) ;
u = t & 0xffffffff ;
c = +( t > 0xffffffff ) ;

return [ ( a[0] + b[0] + c ) & 0xffffffff , u ] ;

} ;

exports.add64 = add64 ;
8 changes: 8 additions & 0 deletions js/src/and64.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

var and64 = function ( a , b ) {

return [ a[0] & b[0] , a[1] & b[1] ] ;

} ;

exports.and64 = and64 ;
11 changes: 11 additions & 0 deletions js/src/big64.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

var big64 = function ( a , o ) {

return [
( a[o + 0] << 24 ) | ( a[o + 1] << 16 ) | ( a[o + 2] << 8 ) | a[o + 3] ,
( a[o + 4] << 24 ) | ( a[o + 5] << 16 ) | ( a[o + 6] << 8 ) | a[o + 7]
] ;

} ;

exports.big64 = big64 ;
Empty file removed js/src/dummy.js
Empty file.
8 changes: 8 additions & 0 deletions js/src/not64.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

var not64 = function ( a ) {

return [ ~a[0] , ~a[1] ] ;

} ;

exports.not64 = not64 ;
26 changes: 26 additions & 0 deletions js/src/rot64.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

var rot64 = function ( a , s ) {

if ( s < 32 ) {

return [
( a[1] << ( 32 - s ) ) | ( a[0] >>> s ) ,
( a[0] << ( 32 - s ) ) | ( a[1] >>> s )
] ;

}

else {

s -= 32 ;

return [
( a[0] << ( 32 - s ) ) | ( a[1] >>> s ) ,
( a[1] << ( 32 - s ) ) | ( a[0] >>> s )
] ;

}

} ;

exports.rot64 = rot64 ;
8 changes: 8 additions & 0 deletions js/src/shr64.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

var shr64 = function ( a , s ) {

return [ a[0] >>> s , ( a[0] << ( 32 - s ) ) | ( a[1] >>> s ) ] ;

} ;

exports.shr64 = shr64 ;
8 changes: 8 additions & 0 deletions js/src/xor64.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

var xor64 = function ( a , b ) {

return [ a[0] ^ b[0] , a[1] ^ b[1] ] ;

} ;

exports.xor64 = xor64 ;
6 changes: 0 additions & 6 deletions test/js/src/dummy.js
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@

test( "dummy" , function () {

ok( false, "tests implemented" );

} );

0 comments on commit a90f38e

Please sign in to comment.