@@ -3808,7 +3808,7 @@ function checksum(val) {
38083808 return sum ;
38093809}
38103810
3811- String . prototype . encrypt = function ( key , isUnique ) {
3811+ String . prototype . encrypt = function ( key , isUnique , secret ) {
38123812 var str = '0' + this ;
38133813 var data_count = str . length ;
38143814 var key_count = key . length ;
@@ -3832,10 +3832,10 @@ String.prototype.encrypt = function(key, isUnique) {
38323832 for ( var i = 0 ; i < str . length ; i ++ )
38333833 sum += str . charCodeAt ( i ) ;
38343834
3835- return ( sum + checksum ( F . config . secret + key ) ) + '-' + str ;
3835+ return ( sum + checksum ( ( secret || F . config . secret ) + key ) ) + '-' + str ;
38363836} ;
38373837
3838- String . prototype . decrypt = function ( key ) {
3838+ String . prototype . decrypt = function ( key , secret ) {
38393839
38403840 var index = this . indexOf ( '-' ) ;
38413841 if ( index === - 1 )
@@ -3846,7 +3846,7 @@ String.prototype.decrypt = function(key) {
38463846 return null ;
38473847
38483848 var hash = this . substring ( index + 1 ) ;
3849- var sum = checksum ( F . config . secret + key ) ;
3849+ var sum = checksum ( ( secret || F . config . secret ) + key ) ;
38503850 for ( var i = 0 ; i < hash . length ; i ++ )
38513851 sum += hash . charCodeAt ( i ) ;
38523852
@@ -3879,6 +3879,19 @@ String.prototype.decrypt = function(key) {
38793879 return counter !== ( val . length + key . length ) ? null : val ;
38803880} ;
38813881
3882+ String . prototype . decryptnumber = function ( salt ) {
3883+ var val = this . decrypt ( salt , F . config [ 'secret-numbers' ] ) ;
3884+ var num = 0 ;
3885+ if ( val ) {
3886+ num = + val ;
3887+ if ( isNaN ( num ) )
3888+ return 0 ;
3889+ for ( var i = 0 ; i < salt . length ; i ++ )
3890+ num -= salt . charCodeAt ( i ) ;
3891+ }
3892+ return num ;
3893+ } ;
3894+
38823895String . prototype . base64ToFile = function ( filename , callback ) {
38833896 var self = this ;
38843897 var index = self . indexOf ( ',' ) ;
@@ -4061,6 +4074,13 @@ String.prototype.removeTags = function() {
40614074 return this . replace ( regexpTags , '' ) ;
40624075} ;
40634076
4077+ Number . prototype . encrypt = function ( salt ) {
4078+ var num = this ;
4079+ for ( var i = 0 ; i < salt . length ; i ++ )
4080+ num += salt . charCodeAt ( i ) ;
4081+ return num . toString ( ) . encrypt ( salt , false , F . config [ 'secret-numbers' ] ) ;
4082+ } ;
4083+
40644084Number . prototype . floor = function ( decimals ) {
40654085 return Math . floor ( this * Math . pow ( 10 , decimals ) ) / Math . pow ( 10 , decimals ) ;
40664086} ;
0 commit comments